私信  •  关注

José Miguel

José Miguel 最近创建的主题
José Miguel 最近回复了

我没有安装和安装Selenium来测试它。
你能试试这个小办法吗?

from selenium import webdriver

import pandas as pd

driver = webdriver.Chrome()

site = 'https://www.goodreads.com/book/show/50148349-manto-and-chughtai?from_search=true&from_srp=true&qid=ZARMElvyyt&rank=3'

driver.get(site)

authors = [ ]

names = driver.find_elements_by_xpath('//div[@class="authorName__container"]')

for name in names:

    authors.append(name.find_element_by_xpath('.//a[@class="authorName"]').text)

authors_in_one_cell = ', '.join(authors)

df = pd.DataFrame({'Author Names': authors_in_one_cell})

df.to_csv("Authors_list.csv", index=False)

print(df)