【发布时间】:2019-09-11 04:10:02
【问题描述】:
我需要下载整页并解析它,但它会在 JavaScript 的帮助下创建一些元素。当我尝试通过帮助 urllib 执行此操作时,我收到一个没有使用 JavaScript 元素的 html 页面。我该如何解决这个问题?
import urllib.request as urlib
page = urlib.urlopen('https://www.example.com')
soup = BeautifulSoup(page, 'html5lib')
...
尝试:
colordiv = soup.select("div.pswp__item:nth-child(1) > div:nth-child(1) > img:nth-child(1)'")[0]
与:
https://www.electrictobacconist.com/smok-nord-p5831
【问题讨论】:
-
您能否附上网址并准确说明您的目标是什么?
-
link 选择颜色
colordiv = soup.select("div.pswp__item:nth-child(1) > div:nth-child(1) > img:nth-child(1)'")[0] -
使用硒...
标签: python web-scraping urllib