"http://ggzyjy.sc.gov.cn/jyxx/transactionInfo.html"编写一段python编程帮我把关键字为智慧城市的招投标信息爬取下来
时间: 2024-02-04 22:03:44 浏览: 36
好的,我可以帮你写一个爬虫程序来实现你的需求。以下是Python代码:
```python
import requests
from bs4 import BeautifulSoup
url = "http://ggzyjy.sc.gov.cn/jyxx/transactionInfo.html"
params = {
"currentPage": 1,
"keyWord": "智慧城市",
"bidType": "",
"informationType": "",
"province": "",
"city": "",
"area": ""
}
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299"
}
res = requests.get(url, params=params, headers=headers)
soup = BeautifulSoup(res.text, "html.parser")
items = soup.select(".ewb-right-item-title a")
for item in items:
print(item.text.strip(), item["href"])
```
这个程序会向目标网站发起GET请求,带上关键字参数和请求头。然后解析返回的HTML文本,提取出所有关键字为“智慧城市”的招投标信息,并打印出它们的标题和链接。注意:为了保护你的隐私,这段代码并没有保存或上传任何与你相关的信息。