我正在尝试将Selenium的源代码保存到.txt中,但.txt文件保持为空。
当我尝试使用命令打印源代码时:
htmlcode = driver.page_source
(driver.page_source).encode('utf-8'))
print(htmlcode)
它将打印源代码,但随后它会导致脚本错误:
File "C:\Python27\lib\encodings\cp850.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode character u'\u20ac' in position 16329: character maps to <undefined>
答案 0 :(得分:2)
问题解决了! 3小时后搜索&#39;: - )
ch = chain(scan_chunk.si([x.id for x in chunk]) for chunk in chunks)()
return ch.get()