摘要: 一、格式化主要用prettify()方法 """基于bs4库的HTML格式化""" import requests from bs4 import BeautifulSoup #方法一:下行遍历 url = "https://python123.io/ws/demo.html" r = reques 阅读全文
posted @ 2020-06-05 00:17 udbful 阅读(287) 评论(0) 推荐(0)
摘要: https://python123.io/ws/demo.html <html><head><title>This is a python demo page</title></head> <body> <p class="title"><b>The demo python introduces s 阅读全文
posted @ 2020-06-04 23:17 udbful 阅读(261) 评论(0) 推荐(0)
摘要: 举例: """Beautiful Soup库的基本元素"""import requestsfrom bs4 import BeautifulSoupurl = "https://python123.io/ws/demo.html"r = requests.get(url)demo = r.texts 阅读全文
posted @ 2020-06-04 22:20 udbful 阅读(225) 评论(0) 推荐(0)
摘要: BeautifulSoup库的安装 Pip install BeautifulSoup4 (anaconda第三方库中已安装BeautifulSoup库) 测试 1 """BeautifulSoup安装测试""" 2 3 4 import requests 5 from bs4 import Bea 阅读全文
posted @ 2020-06-04 17:02 udbful 阅读(331) 评论(0) 推荐(0)
摘要: IP地址归属地的自动查询 1 """IP地址归属地查询""" 2 3 4 import requests 5 6 #url = "http://m.ip138.com/ip.asp?ip=" 7 url = "https://www.ip138.com/iplookup.asp?ip=" 8 try 阅读全文
posted @ 2020-06-04 10:34 udbful 阅读(275) 评论(0) 推荐(0)
摘要: 1 """使用多线程爬取梨视频视频数据""" 2 """https://www.cnblogs.com/zivli/p/11614103.html""" 3 4 5 import requests 6 import re 7 from lxml import etree 8 from multipr 阅读全文
posted @ 2020-06-04 10:25 udbful 阅读(248) 评论(0) 推荐(0)
摘要: 网络图片的爬取和存储 1 """网络图片的爬取和存储""" 2 3 4 import requests 5 import os 6 7 url = "http://image.nationalgeographic.com.cn/2017/0211/20170211061910157.jpg" 8 r 阅读全文
posted @ 2020-06-04 10:22 udbful 阅读(179) 评论(0) 推荐(0)
摘要: 1 """百度搜索关键词提交""" 2 3 4 import requests 5 6 url = "https://www.baidu.com/s" 7 keyword = "Python" #中文也没问题 8 try: 9 kv = {'wd': 'keyword'} 10 r = reques 阅读全文
posted @ 2020-06-04 10:15 udbful 阅读(206) 评论(0) 推荐(0)
摘要: 1 """实例1:京东商品页面的爬取""" 2 3 4 import requests 5 6 url = "https://item.jd.com/100012545852.html" 7 try: 8 # 更改头部信息 9 kv = {'user-agent': 'Mozilla/5.0'} 1 阅读全文
posted @ 2020-06-04 10:05 udbful 阅读(273) 评论(0) 推荐(0)
摘要: 6 网络爬虫引发的问题及Robots协议 阅读全文
posted @ 2020-06-04 09:56 udbful 阅读(157) 评论(0) 推荐(0)