【爬虫】bs4新发地
# -*- coding:utf-8 -*-
import requests
import csv
from bs4 import BeautifulSoup
url = "http://www.xinfadi.com.cn/priceDetail.html"
resp = requests.get(url)
page = BeautifulSoup(resp.text, "html.parser")
thd = page.find("thead")
trs = thd.find_all("tr")[1:]
for tr in trs:
ths = tr.find_all("th")
first = ths[0].text
second = ths[1].text
name = ths[2].text
print(first, second, name)
浙公网安备 33010602011771号