且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python2.7 硒错误

更新时间:2023-12-01 16:48:58

尝试在 print(post2.text)

A=post2.text

A=A.encode('ascii','ignore')

而不是 text_file.write(post2.text + "\n")text_file.write(A + "\n")

它对我有用.

要调试下一个按钮问题,请尝试以下代码:

to debug next button issue try the following code:

for n in range(10):
nextbutton = 0
try:
    nextbutton = driver.find_element_by_xpath("//*[@id='pnnext']/span[2]")
    if nextbutton !=0 :
        nextbutton.click()
except: pass
time.sleep(5)
if nextbutton != 0 or n==0:
    posts2 = driver.find_elements_by_class_name("_Rm")
    for post2 in posts2:
        print(post2.text)
        A=post2.text
        A=A.encode('ascii','ignore')
        text_file.write(A + "\n")