“十六进制转义的意外结束”是什么意思

 收藏

使用硒刮网站时出现此错误。它似乎是我刮擦的文本的问题,因为如果刮擦了一个小样本,它就可以正常工作。

我在用 firefox geckodriver版本0.26 硒版本3.141.0

for i in range(0,int(total_items/12)):
    if pp == 1:
        driver.find_element_by_css_selector('div._1kjvp19').click()  # items in page
        driver.execute_script('window.scrollTo(0, document.body.scrollHeight);')
        WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.XPATH, '//*[@id="db-item-list"]/div[4]/a[8]')))
        row_count0 = len(driver.find_elements_by_xpath('//*[@id="db-item-list"]/div[4]/a'))+5
        print(row_count0)
        pp=0
    driver.execute_script('window.scrollTo(0, document.body.scrollHeight);')
    total_rows= row_count0+row_count
    print(total_rows)
    WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.XPATH, '//*[@id="db-item-list"]/div[4]/a['+str(total_rows)+']')))
    row_count = len(driver.find_elements_by_xpath('//*[@id="db-item-list"]/div[4]/a'))+5
    print(row_count)
    row_count0=0
print('out')

soup = BeautifulSoup(driver.page_source, 'lxml')
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.4\plugins\python-ce\helpers\pydev\pydevd.py", line 1434, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.4\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/me/Desktop/update1.py", line 143, in <module>
    soup = BeautifulSoup(driver.page_source, 'lxml')
  File "C:\Users\me\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py", line 679, in page_source
    return self.execute(Command.GET_PAGE_SOURCE)['value']
  File "C:\Users\me\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\me\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: unexpected end of hex escape at line 1 column 1124227
回复