【发布时间】:2021-06-01 00:29:07
【问题描述】:
我是使用 python 进行网络抓取的新手。我已经成功地学会了从一些网站上抓取信息,例如https://www.jameda.de 和维基百科。但是我遇到了一个网站,在搜索特定数据时不会打开新的网络链接。我无法理解如何抓取该网站。非常感谢任何帮助。
网站: https://www.kvwl.de/earzt/index.htm
在搜索字段中,您可以在(Ihr Standort)字段中输入例如“柏林,德国”并查看网址,它不会改变。我还查看了检查字段,我看不到任何用于抓取数据的链接。
非常感谢任何帮助!
以下是我用来从其他网站提取信息的代码:
import requests
from bs4 import BeautifulSoup, NavigableString, Tag
import urllib.request
import re
base_site = "https://www.tk-aerztefuehrer.de/TK/Suche_SN/index.js?a=DL&Otn1=798&Ic1=127&Ftg=33014+Bad+Driburg&Ftg_e=&Lng=36"
response = requests.get(base_site)
response.status_code
html = response.content
html
soup = BeautifulSoup(html, 'lxml')
with open('TK_33014_Bad_Driburg_LXML.html','wb') as file:
file.write(soup.prettify('utf-8'))
divs = soup.find_all("div",{"class": "card dl"})
headings = [div.find('a').text for div in divs]
headings
【问题讨论】:
-
让我猜猜:标题是
empty,div 是empty。 -
您可能需要使用
selinium -
感谢 Ajay 的提示。我会调查的!!
标签: python web-scraping beautifulsoup scrapy