【发布时间】:2020-04-14 10:38:13
【问题描述】:
当我尝试 scrape 跟随 url 时,selenium 大约 30 秒没有响应,然后在漂亮的汤线上发出错误,因为没有要解析的 html 代码。我的 selenium + chrome 设置适用于大多数网站,但不是这个:http://www.11st.co.kr/product/SellerProductDetail.tmall?method=getSellerProductDetail&prdNo=2609814501&trTypeCd=22&trCtgrNo=895019
我应该怎么做才能让它工作?
这是我的硒选项:
def GetSelenium():
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_argument("--disable-infobars")
options.add_argument('headless')
options.add_argument('lang=ko_KR')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36')
driver = webdriver.Chrome('/usr/bin/chromedriver',chrome_options=options)
return driver
@api_view()
def crawlOthers(request, crawl_url):
crawl_url = request.data["requestUrl"]
print("URL:" + crawl_url)
driver = GetSelenium()
driver.get(crawl_url)
html = driver.page_source
driver.quit()
bsObj = BeautifulSoup(html,'html.parser')
#parsing deleted
【问题讨论】:
标签: selenium google-chrome web-scraping web-crawler