python爬虫,无法抓出A标签的文字,应该怎么处理?
#!/usr/bin/python#coding:utf-8importrequestsfrombs4importBeautifulSoup#从bs4这个库中导入Beau...
#!/usr/bin/python
# coding: utf-8
import requests
from bs4 import BeautifulSoup #从bs4这个库中导入BeautifulSoup
i = 0
link = "https://www.d1ev.com/carnews/xinche/list-2"
headers = {'User-Agent' : 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'}
r = requests.get(link, headers= headers)
soup = BeautifulSoup(r.text, "html.parser")
for news in soup.select('.article--wraped.am-cf'):
title = news.select('a')[0].string
print(title) 展开
# coding: utf-8
import requests
from bs4 import BeautifulSoup #从bs4这个库中导入BeautifulSoup
i = 0
link = "https://www.d1ev.com/carnews/xinche/list-2"
headers = {'User-Agent' : 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'}
r = requests.get(link, headers= headers)
soup = BeautifulSoup(r.text, "html.parser")
for news in soup.select('.article--wraped.am-cf'):
title = news.select('a')[0].string
print(title) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询