# -*- coding:UTF-8 -*- import requests,time from collections import OrderedDict import threading from bs4 import BeautifulSoup as bp t3 = time.time() ... ...
分类:
编程语言 时间:
2017-06-02 17:23:48
阅读次数:
202
上一篇文章《Python爬虫:抓取新浪新闻数据》详细解说了如何抓取新浪新闻详情页的相关数据,但代码的构建不利于后续扩展,每次抓取新的详情页时都需要重新写一遍,因此,我们需要将其整理成函数,方便直接调用。 详情页抓取的6个数据:新闻标题、评论数、时间、来源、正文、责任编辑。 首先,我们先将评论数整理成 ...
分类:
编程语言 时间:
2017-06-02 13:28:54
阅读次数:
275
#!/sur/bin/python#conding=utf-8import urllib.requestfrom bs4 import BeautifulSoupurl="http://www.shicimingju.com/book/sanguoyanyi.html" # 要爬取的网络地址menu ...
分类:
编程语言 时间:
2017-05-29 22:53:49
阅读次数:
336
https://www.crummy.com/software/BeautifulSoup/bs4/doc.zh/#id4 中文版BeautifulSoup库 作用 提取HTML和XML文档中的数据 修改、导航、查找文档 创建html_doc >>> html_doc = """... <html> ...
分类:
其他好文 时间:
2017-05-29 12:04:02
阅读次数:
212
1 import re 2 import urllib.request 3 from bs4 import BeautifulSoup 4 import time 5 6 url=input("输入任一页的网址:") 7 8 def gethtml(url): 9 #获取页面源代码... ...
分类:
编程语言 时间:
2017-05-25 13:26:13
阅读次数:
258
1 import re 2 import urllib.request 3 from bs4 import BeautifulSoup 4 import time 5 6 url=input("第一章网址:") 7 8 def gethtml(url): 9 #获取页面源代码htm... ...
分类:
编程语言 时间:
2017-05-24 22:44:32
阅读次数:
254
解决bs4在Python 3.5下出现“ImportError: cannot import name 'HTMLParseError'”错误 分类:Python (4251) (3) 分类:Python (4251) (3) 升级了Python3.5之后,我使用BeautifulSoup4时候出现 ...
分类:
其他好文 时间:
2017-05-20 11:09:29
阅读次数:
224