【问题标题】:Storing scraped values in csv files将抓取的值存储在 csv 文件中
【发布时间】:2021-06-11 09:11:02
【问题描述】:

作为我大学项目的一部分,我正在做 LinkedIn 网页抓取。我已经刮掉了个人资料的经验和教育部分。之后,我想将其保存在 csv 文件中,如下面的代码所示。但它被存储为对象地址而不是实际值。如何保存经验和教育的实际值,而不是对象地址?

#Code to scrape experience and education sections of a LinkedIn profile
experience = driver.find_elements_by_css_selector('#experience-section .pv-profile-section')
education = driver.find_elements_by_css_selector('.education-section ')

with open('linkedin.csv', 'w', newline='') as file:
    writer = csv.writer(file)
    writer.writerow(["Sr. No.", "Experience", "Education"])
    writer.writerow([1, experience, education])

它是这样保存的:

【问题讨论】:

    标签: selenium csv web-scraping export-to-csv


    【解决方案1】:
    experiencetext= [x.text for x in experience]
    

    将其转换为文本列表。那就通过吧。

    【讨论】:

    • 我尝试使用它,但它使用 '\n' 标签存储值。我该如何删除这些? ['实习生\n公司名称\nMedTourEasy实习\n工作日期\n2020年4月-2020年6月\n工作时间\n3个月\n在数据可视化领域工作以收集和分析数据;并在 COVID-19 上创建用户交互式仪表板。在全球范围内创建 COVID-19 并测试跟踪器以获得有意义的见解。利用 PowerBI、Tableau 和 R。']
    • x.text.replace("\n","")
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-16
    • 2017-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多