import re from bs4 import BeautifulSoup html_doc = """ <html><head><title>The Dormouse's story</title></head> <body> <p class="title"><b>The Dormouse' ...
分类:
其他好文 时间:
2016-11-30 02:50:15
阅读次数:
250
import requestsfrom bs4 import BeautifulSoupres = requests.get('http://news.sina.com.cn/china/')res.encoding='utf-8'soup = BeautifulSoup(res.text,'htm ...
分类:
其他好文 时间:
2016-11-27 19:23:08
阅读次数:
206
request能取到网页上面的数据,但是这些是属于结构化的数据,我们不能直接使用,需要将这些数据进行转化,从而方便使用 BeautifulSoup能将标签移除掉,从而获得网页上的数据以及内容 1、将特定标签的内容取出来 单个标签 ...
分类:
其他好文 时间:
2016-11-27 19:01:50
阅读次数:
142
看到了中文版的python tutorial,发现是网页版的,刚好最近在学习爬虫,想着不如抓取到本地 首先是网页的内容 查看网页源码后发现可以使用BeautifulSoup来获取文档的标题和内容,并保存为doc文件。 这里需要使用from bs4 import BeautifulSoup 来导入该模 ...
分类:
编程语言 时间:
2016-11-27 07:26:36
阅读次数:
167
用python+bs4爬取了手机归属地数据: import urllib.request from bs4 import BeautifulSoup def spider1(url): headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1) App ...
分类:
移动开发 时间:
2016-11-25 17:28:06
阅读次数:
256
BeautifulSoup很赞的东西 最近出现一个问题:Python 3.3 soup=BeautifulSoup(urllib.request.urlopen(url_path),"html.parser") soup.findAll("a",{"href":re.compile('^http|^ ...
分类:
其他好文 时间:
2016-11-19 13:04:14
阅读次数:
419
接着上一次爬虫我们继续研究BeautifulSoup Python简单爬虫入门一 上一次我们爬虫我们已经成功的爬下了网页的源代码,那么这一次我们将继续来写怎么抓去具体想要的元素 首先回顾以下我们BeautifulSoup的基本结构如下 重要事情再次强调这是我们开始爬取网页的一个基本结构,如同建楼的一 ...
分类:
编程语言 时间:
2016-11-17 12:42:01
阅读次数:
200
本文利用Python3爬虫抓取豆瓣图书Top250,并利用xlwt模块将其存储至excel文件,图片下载到相应目录。旨在进行更多的爬虫实践练习以及模块学习。 工具 1.Python 3.5 2.BeautifulSoup、xlwt模块 开始动手 首先查看目标网页的url: https://book. ...
分类:
编程语言 时间:
2016-11-15 08:19:12
阅读次数:
268
result: .<a class="sister" href="http://example.com/elsie" id="xiaodeng"><!-- Elsie --></a><a class="sister" href="http://example.com/lacie" id="link2 ...
分类:
编程语言 时间:
2016-11-14 01:29:34
阅读次数:
189