我想抓取 the following webpage .
搜索框(上面写着输入安全名称/代码/ID)是我遇到困难的地方。我无法使用 xpath 抓取它,我正在使用 mechanize 库进行浏览器模拟,但它似乎不起作用。
我遇到了这个问题 Excel VBA Scrape Web Page这与我的问题非常相似,但我不知道如何使用 Python 来实现它。
我试过的代码:
import mechanize
from bs4 import BeautifulSoup
import requests
url = 'https://www.bseindia.com/corporates/corporate_act.aspx'
res = requests.get(url)
soup = BeautifulSoup(res.text, "html.parser")
br = mechanize.Browser()
br.open(url)
br.select_form(nr=0)
br['ContentPlaceHolder1_SmartSearch_smartSearch'] = input("enter the company name")
response = br.submit()
PS:我是网络抓取的新手,我想知道大学项目的解决方案,因此非常感谢您的帮助。
最佳答案
我建议你使用 scrapy框架。我认为它是更先进的工具之一,包括模拟与站点交互的工具。
关于python - 有没有一种特殊的方法来抓取动态网站?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60044303/