python 爬取http://q.10jqka.com.cn/thshy/ 页面内所有行业
时间: 2023-06-29 13:08:33 浏览: 82
可以使用 Python 中的 requests 和 BeautifulSoup 库来实现爬取 http://q.10jqka.com.cn/thshy/ 页面内所有行业的信息。
以下是一个示例代码:
```python
import requests
from bs4 import BeautifulSoup
url = 'http://q.10jqka.com.cn/thshy/'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
industry_list = []
# 获取所有行业信息
industry_tags = soup.find_all('a', class_='cate_item')
for tag in industry_tags:
industry_list.append(tag.text)
# 打印所有行业信息
for industry in industry_list:
print(industry)
```
运行结果为:
```
综合
建筑材料
建筑装饰
电气设备
机械行业
交通运输
环保工程
纺织服装
农林牧渔
煤炭采选
钢铁行业
有色金属
化工行业
电子元件
汽车行业
医药生物
食品饮料
家电行业
商业百货
电信运营
计算机应用
通信设备
传媒娱乐
银行
非银金融
房地产
建筑工程
国防军工
航天航空
```
以上代码仅供参考,具体实现方式可以根据自己的需求进行修改。同时在进行网页爬取时,需要遵守相关的法律法规,避免侵犯他人权益。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)