【发布时间】:2016-03-19 02:35:50
【问题描述】:
我正在尝试抓取一个网站,我遇到的问题是页面需要时间来加载。因此,当我的抓取完成时,我可能只得到 5 个项目,而可能有 25 个项目。有没有办法减慢 python 的速度。我正在使用美丽的汤 这是我正在使用的代码
import urllib
import urllib.request
from bs4 import BeautifulSoup
theurl="http://agscompany.com/product-category/fittings/tube-nuts/316-tube/"
thepage = urllib.request.urlopen(theurl)
soup = BeautifulSoup(thepage,"html.parser")
for pn in soup.find_all('div',{"class":"shop-item-text"}):
pn2 = pn.text
print(pn2)
谢谢
【问题讨论】:
-
请发布您的代码...
-
更有可能是网页使用javascript在用户滚动时加载更多项目。
-
已添加代码 - 抱歉
标签: python-3.x web-scraping beautifulsoup