Beautifulsoup分解
from urllib.request import Request, ProxyHandler
from urllib.request import build_opener
from bs4 import BeautifulSoup
import redis
urlfront = "http://www.xicidaili.com"
url = "http://www.xicidaili.com/nn/1"
r = redis.Redis(host='127.0.0.1', port=,db=) # def spider_IP(url):
# 获取整个页面
def get_allcode(url):
# 设置代理IP
proxy = {'https': '110.73.0.45:8123'}
proxy_support = ProxyHandler(proxy);
opener = build_opener(proxy_support)
# 设置访问http协议头,模拟浏览器
opener.addheaders = [
('User-agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6')]
r = opener.open(url)
html = r.read().decode("UTF-8");
# print(html)
return str(html) # 根据URl用beautifulsoup提取,可以写方法
def find_ip(s):
soup = BeautifulSoup(s, 'html.parser');
aList = soup.find_all(name="tr",class_="odd")
for items in aList:
link = items.find_all("td")
print("%s:%s" %(link[].get_text(),link[].get_text()))
find_ip(get_allcode(url))
Beautifulsoup分解的更多相关文章
- [python] 网络数据采集 操作清单 BeautifulSoup、Selenium、Tesseract、CSV等
Python网络数据采集操作清单 BeautifulSoup.Selenium.Tesseract.CSV等 Python网络数据采集操作清单 BeautifulSoup.Selenium.Tesse ...
- BeautifulSoup 库的使用记录
BeautifulSoup 有何用途 如果我们需要通过脚本来抓取网络中的数据时,使用传统的字符解析等方法时是非常低效的,而BeautifulSoup则可以方便的通过接口来获取标签中所想要得到的数据.主 ...
- python3 调用 beautifulSoup 进行简单的网页处理
python3 调用 beautifulSoup 进行简单的网页处理 from bs4 import BeautifulSoup file = open('index.html','r',encodi ...
- 06.LoT.UI 前后台通用框架分解系列之——浮夸的图片上传
LOT.UI分解系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#lotui LoT.UI开源地址如下:https://github.com/du ...
- 07.LoT.UI 前后台通用框架分解系列之——强大的文本编辑器
LOT.UI分解系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#lotui LoT.UI开源地址如下:https://github.com/du ...
- 01.LoT.UI 前后台通用框架分解系列之——小图片背景全屏显示(可自动切换背景)
LOT.UI分解系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#lotui LoT.UI开源地址如下:https://github.com/du ...
- 02.LoT.UI 前后台通用框架分解系列之——灵活的菜单栏
LOT.UI分解系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#lotui LoT.UI开源地址如下:https://github.com/du ...
- 03.LoT.UI 前后台通用框架分解系列之——多样的表格
LOT.UI分解系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#lotui LoT.UI开源地址如下:https://github.com/du ...
- 04.LoT.UI 前后台通用框架分解系列之——轻巧的弹出框
LOT.UI分解系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#lotui LoT.UI开源地址如下:https://github.com/du ...
随机推荐
- maven中jetty插件配置
maven中jetty插件的配置,可用于项目在内置jetty服务器中的部署. <plugin> <groupId>org.mortbay.jetty</groupId&g ...
- How the Intelligent Digital Mesh Will Transform Every Business Layer
The "intelligent digital mesh" is the definitive package for tomorrow's titans of business ...
- vi 编辑器笔记
摘要: vi从安装到使用 vi从菜鸟到高手 0. vim - Vi IMproved, a programmers text editor 分为 VI和VIM,现在流行的发行版里面VI=VIM 是一个 ...
- swift 之 函数
swift的函数跟脚本语言有很多神似之处. 如果有一天用swift开发服务器 ,很期待哇(一切皆有可能,毕竟人家说要跑在Linux上),
- continous integration environment (Jenkins and bitbucket configuration)
================================================================================ continous integrati ...
- HDU1255覆盖的面积
覆盖的面积 Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submis ...
- HDU 4267 A Simple Problem with Integers(树状数组区间更新)
A Simple Problem with Integers Time Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K ...
- 跨域请求CORS
参考:https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Access_control_CORS http://www.ruanyifeng.com/b ...
- ueditor 和 umeditor 粘贴过滤问题
最近遇到需要将WORD WPS等复制的带有格式的内容粘贴到富文本编辑器里面去掉冗余的HTML,只保留最有用的部分. 第一步肯定是先查官方文档了. http://fex.baidu.com/uedito ...
- JavaWeb笔记一、Servlet 详解
一.创建一个 Servlet 简单实现类 1.创建一个 HelloServlet 类(测试 Servlet 接口方法) 1 //创建一个 HelloServlet 类并实现 Servlet 接口 2 ...