【发布时间】:2019-01-05 11:04:50
【问题描述】:
scrape.py
# code to scrape the links from the html
from bs4 import BeautifulSoup
import urllib.request
data = open('scrapeFile','r')
html = data.read()
data.close()
soup = BeautifulSoup(html,features="html.parser")
# code to extract links
links = []
for div in soup.find_all('div', {'class':'main-bar z-depth-1'}):
# print(div.a.get('href'))
links.append('https://godamwale.com' + str(div.a.get('href')))
print(links)
file = open("links.txt", "w")
for link in links:
file.write(link + '\n')
print(link)
我已使用此代码成功获取链接列表。但是当我想从他们的 html 页面中从这些链接中抓取数据时,这些没有任何包含数据的源代码,并且提取它们是我的工作艰难。我使用过 selenium driver ,但对我来说效果不佳。 我想从下面的链接中抓取数据,其中包含 html 部分中的数据,其中包含客户详细信息、许可证和自动化、商业详细信息、楼层明智、操作详细信息。我想提取这些带有姓名、位置、联系电话和类型的数据。
https://godamwale.com/list/result/591359c0d6b269eecc1d8933
这里是链接。如果有人找到解决方案,请给我。
【问题讨论】:
-
以前有人做过吗?
-
“哪个没有源代码”没看懂?什么意思详细解释一下
-
当我使用 ctrl + u 查看源代码时,它只显示其中没有数据的代码,但我想废弃数据,当我检查时找到数据代码。
-
你说你有链接,但没有提到你接下来想做什么
-
我想从这些链接中删除数据,一个一个地把它们放到一个excel文件中
标签: python-3.x web-scraping beautifulsoup