【发布时间】:2017-09-27 21:48:48
【问题描述】:
背景:我刚学了两天“Webdriver”和“Beautifulsoup”。
问题: 我使用以下代码下载网页:
from selenium import webdriver
from bs4 import BeautifulSoup
driver = webdriver.PhantomJS(executable_path)
driver.get('https://mojim.com/twy100468x17x18.htm')
pageSource = driver.page_source
...
然后,我遇到了这个错误
WebDriverException: Message: URIError - String contained an illegal UTF-16 sequence.
尝试:我尝试将pageSource = browser.page_source 替换为(driver.page_source).encode('ascii', 'ignore')(driver.page_source).encode('utf-8')
(here建议)
但仍然以同样的错误结束....
网页来源 here
我该怎么办? html中是否有非法文本或什么?
谢谢
【问题讨论】:
标签: html selenium beautifulsoup python-3.5