导出到csv时重复抓取的数据

时间:2021-02-03 18:31:33

标签: python selenium web-scraping beautifulsoup web-crawler

我正在尝试从这个 web 抓取数据
我的想法是抓取网络上的所有链接,然后使用 for 将请求发送到每个链接以获取详细信息数据。

这是我的code,如你所见,我使用 selenium web 驱动程序打开 URL,然后使用漂亮的汤来抓取数据。

嗯 它运行得相当成功,但是当它导出到 CSV 文件时,第一个下链接的 upload_datenumber_employees 的类别与下面的第一个相同
image
每个链接中upload_datenumber_employees的{​​{1}}在页面中显示为这个框enter image description here
我应该如何销售这个问题?
衷心感谢。 <3 P/s:我还有一个问题是我需要登录网络来抓取每个链接中的 salary 但我还没有找到答案

1 个答案:

答案 0 :(得分:2)

当您尝试保存抓取的数据时,您总是在循环中附加相同的值,这里:

upload_date = content[0]
position = content[1]
career = content[2]
skill = content[3]
language_of_cv = content[4]
detail_address = content[5]
number_employees = content[6]

您必须遍历抓取的数据才能将所有内容保存在 csv 文件中。