Python爬虫BeautifulSoup用法(1)
来源:互联网 发布:淘宝上正规药店是哪个 编辑:程序博客网 时间:2024/06/05 05:24
爬新浪新闻网页
import requests
from bs4 import BeautifulSoup
res=requests.get('http://news.sina.com.cn/china/')
res.encoding='utf-8'
soup=BeautifulSoup(res.text,'html.parser')
for news in soup.select('.news-item'):
if len(news.select('h2'))>0:
h2=news.select('h2')[0].text
print(h2)
提取新闻标题
import requests
from bs4 import BeautifulSoup
res=requests.get('http://news.sina.com.cn/china/xlxw/2017-12-09/doc-ifyppemf6082547.shtml')
res.encoding='utf-8'
soup=BeautifulSoup(res.text,'html.parser')
title=soup.select('#artibodyTitle')[0].text
print(title)
阅读全文
0 0
- Python爬虫BeautifulSoup用法(1)
- python爬虫--BeautifulSoup的简单用法
- python简单爬虫 及 beautifulSoup简单用法
- python爬虫之BeautifulSoup的用法
- Python-网络爬虫之BeautifulSoup(1)
- python爬虫之BeautifulSoup
- python爬虫之-BeautifulSoup
- python beautifulsoup 爬虫学习
- python爬虫之BeautifulSoup
- python-爬虫-beautifulsoup
- python爬虫爬取斗图网BeautifulSoup
- python爬虫--BeautifulSoup
- python爬虫(BeautifulSoup)
- [爬虫] Python爬虫 urllib BeautifulSoup
- python 自己写爬虫 ----- BeautifulSoup
- python 爬虫试手 requests+BeautifulSoup
- python 爬虫 beautifulsoup example 例子
- python爬虫之BeautifulSoup入门
- python 爬取新浪网站 NBA球员最近2个赛季库里前20场数据
- 判断无向图图的连通性,邻接矩阵表示
- JavaFX之实现桌面应用的界面跳转
- UBOOT timer设置(基于S3C2440)
- australian dairy
- Python爬虫BeautifulSoup用法(1)
- BeautifulSoup爬虫之保存到mysql数据库
- 二分查找---河中跳房子
- 谁记得
- Qt 5设置自定义注释片段或者代码片段
- JSP向Servlet传递数组参数
- Jackson之jackson-databind
- 使用交叉存取得到更快推荐算法
- git github 写的比较好的博文