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分解的更多相关文章

  1. [python] 网络数据采集 操作清单 BeautifulSoup、Selenium、Tesseract、CSV等

    Python网络数据采集操作清单 BeautifulSoup.Selenium.Tesseract.CSV等 Python网络数据采集操作清单 BeautifulSoup.Selenium.Tesse ...

  2. BeautifulSoup 库的使用记录

    BeautifulSoup 有何用途 如果我们需要通过脚本来抓取网络中的数据时,使用传统的字符解析等方法时是非常低效的,而BeautifulSoup则可以方便的通过接口来获取标签中所想要得到的数据.主 ...

  3. python3 调用 beautifulSoup 进行简单的网页处理

    python3 调用 beautifulSoup 进行简单的网页处理 from bs4 import BeautifulSoup file = open('index.html','r',encodi ...

  4. 06.LoT.UI 前后台通用框架分解系列之——浮夸的图片上传

    LOT.UI分解系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#lotui LoT.UI开源地址如下:https://github.com/du ...

  5. 07.LoT.UI 前后台通用框架分解系列之——强大的文本编辑器

    LOT.UI分解系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#lotui LoT.UI开源地址如下:https://github.com/du ...

  6. 01.LoT.UI 前后台通用框架分解系列之——小图片背景全屏显示(可自动切换背景)

    LOT.UI分解系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#lotui LoT.UI开源地址如下:https://github.com/du ...

  7. 02.LoT.UI 前后台通用框架分解系列之——灵活的菜单栏

    LOT.UI分解系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#lotui LoT.UI开源地址如下:https://github.com/du ...

  8. 03.LoT.UI 前后台通用框架分解系列之——多样的表格

    LOT.UI分解系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#lotui LoT.UI开源地址如下:https://github.com/du ...

  9. 04.LoT.UI 前后台通用框架分解系列之——轻巧的弹出框

    LOT.UI分解系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#lotui LoT.UI开源地址如下:https://github.com/du ...

随机推荐

  1. LINUX 笔记-date命令

    显示当前时间: 命令: focus@ubuntu:~$ date Thu Aug 31 03:01:17 PDT 2017 focus@ubuntu:~$ date '+%x' 08/31/2017 ...

  2. JAVA基础知识总结:十

    一.抽象类 1.定义 当多个类中出现相同功能,但是功能主体是不同的,这是可以进行向上抽取的,只抽取功能的定义部分,使用抽象类实现 抽象类的存在就是为了被继承 2.使用 abstract 3.抽象类的特 ...

  3. Andrew 机器学习课程笔记

    Andrew 机器学习课程笔记 完成 Andrew 的课程结束至今已有一段时间,课程介绍深入浅出,很好的解释了模型的基本原理以及应用.在我看来这是个很好的入门视频,他老人家现在又出了一门 deep l ...

  4. JQ编写楼层效果

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...

  5. HDU 4135 Co-prime(容斥+数论)

    Co-prime Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  6. code force 401B. Game of Credit Cards

    B. Game of Credit Cards time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  7. 暑假练习赛 003 B Chris and Road

    B - Chris and Road Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144K ...

  8. ssh连接虚拟机失败解决办法

    首先,你需要知道本机IP跟虚拟机IP,然后让两者互相ping一下,看能否ping通 让主机ping虚拟机 :ping (虚拟机ip) 出现如下: 表示主机可以ping通虚拟机 然后让虚拟机ping主机 ...

  9. 你不知的DOM编程

    前言:随着vue,react, angular的流行,可能现在我们不必经常的操作DOM,三大框架在副交互的操作中发挥着极大地优势.因为我们知道用脚本对DOM的操作非常昂贵,本文主要探讨常规的DOM操作 ...

  10. Linux系统安装_Centos6.9

    第1章 虚拟机安装  1.1 镜像下载 1.1.1 新版本下载 http://mirrors.aliyun.com  #阿里云官方镜像站点 1.1.2 旧版本下载 http://vault.cento ...