国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

python爬蟲(chóng)應(yīng)用——爬取中關(guān)村在線(xiàn)的多個(gè)品牌多個(gè)交換機(jī)設(shè)備信息

2023-04-13 22:19 作者:真是累的很啊  | 我要投稿

結(jié)果如下

代碼

import requests
from bs4 import BeautifulSoup as bs4
def main(name):
? ?name=name
? ?url="https://detail.zol.com.cn/switches/{}/".format(name)

? ?response=requests.get(url=url)
? ?dict1={}
? ?html_text=bs4(response.text,'lxml')
? ?sw_url=html_text.select('.pro-intro')[:3]

? ?for i in sw_url:
? ? ? ?for j in i.select('h3'):
? ? ? ? ? ?name=j.text[1:-1]
? ? ? ? ? ?for k in j.select('a'):
? ? ? ? ? ? ? ?dict1[name]='https://detail.zol.com.cn'+k.attrs['href']
? ?return dict1



def get_info(items):
? ?import requests
? ?from bs4 import BeautifulSoup as bs4
? ?url=items[1]
? ?rp=requests.get(url=url).text
? ?bs4_obj=bs4(rp,'lxml')
? ?tr=bs4_obj.select('.enterprise-level_table tr')

? ?dict_info={}
? ?list_info=[]
? ?for i in tr:
? ? ? ?for j in i.select('td')[1]:
? ? ? ? ? ?list_info.append(j.text)

? ?dict_info[items[0]]=list_info
? ?return dict_info

import csv
for n in ['huawei','h3c','ruijie','cisco']:
? ?for i in main(n).items():
? ? ? ?for j in get_info(i).items():
? ? ? ? ? ?with open("./info.csv", 'a', encoding='utf-8', newline='') as f:
? ? ? ? ? ? ? ?f_csv = csv.writer(f)
? ? ? ? ? ? ? ?f_csv.writerow([j[0]]+j[1][:8])
? ? ? ? ? ?print(j[0],' '.join(j[1][:8]))

python爬蟲(chóng)應(yīng)用——爬取中關(guān)村在線(xiàn)的多個(gè)品牌多個(gè)交換機(jī)設(shè)備信息的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
白河县| 邵阳市| 兴海县| 临洮县| 吐鲁番市| 治多县| 韶关市| 呼伦贝尔市| 昌乐县| 毕节市| 凤山县| 盖州市| 哈密市| 搜索| 玉龙| 宁陵县| 苏尼特左旗| 东莞市| 浮梁县| 察隅县| 洪雅县| 荔波县| 栾川县| 隆昌县| 舒兰市| 林甸县| 高雄市| 武汉市| 五常市| 宜良县| 庆安县| 阿鲁科尔沁旗| 柳州市| 广元市| 兴仁县| 三台县| 怀安县| 高平市| 玉树县| 信丰县| 大荔县|