from bs4 import BeautifulSoup import requests url ='http://news.sina.com.cn/china/' html =requests.get(url) html.encoding ='utf-8' soup =BeautifulSoup(html.text,'lxml') links=soup.select('.blk122') x = links[0].find_all('a') for a in x: titles =a.text lianjie =a['href'] print(titles ,lianjie)
简单的爬取新浪新闻标题与链接
最新推荐文章于 2021-02-21 06:37:17 发布