zoukankan      html  css  js  c++  java
  • python子域名收集器

    今天心血来潮做了一个子域名收集器。过程是蛋疼啊!这里先感谢一下qpython群的咸鱼大佬,在换页的时候出了点毛病,讲到后面我们就知道了。

    思路:

     

    代码开始:

    我们要用到的模块是

    Requests

    Bs4模块里的BeautifulSoup

    Time模块

    如果BeautifulSoup没有

    安装方法:

    LINUXsudo pip install bs4

    WINDOWS:pip install bs4

    Import requests

    From bs4 import BeautifulSoup

    Import time

    For i in range(48):

      I=i*10#48*10=50我们爬50

    Heads={'User-Agent': 'Mozilla/5.0(Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0'

    }#将自己伪装成浏览器

    Url=”https://cn.bing.com/search?q=site%3adgjy.net&qs=n&sp=-1&pq=site%3adgjy.net&sc=2-11&sk=&cvid=C1A7FC61462345B1A71F431E60467C43&toHttps=1&redig=3FEC4F2BE86247E8AE3BB965A62CD454&pn=2&first={}&FORM=PERE”.format(i)#占位符会报错

    #解析:q=你要搜索的东西 first=页数

    First=1为第一页

    First=10为第二页

    以此类推

    Html=request.urlopen(url,headers=heads)

    soup=BeautifulSoup(html.content,'html.parser')

    Job=soup.findAll(‘h2’)#列出h2标签

    For i in job:

      Time.sleep(3)#延迟3,防止被必应发现

      Print(i.a.get(‘href’))

    运行结果:

     

    总结:

     

     脚本代码:

    import requests
    from bs4 import BeautifulSoup
    import time
    for i in range(48):
        i=i*10
        heads={
          'User-Agent': 'Mozilla/5.0(Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0'
      }
        url='https://cn.bing.com/search?q=site%3Adgjy.net&qs=n&form=QBRE&sp=-1&pq=site%3Adgjy.net&sc=2-11&sk=&cvid=C1A7FC61462345B1A71F431E60467C43&toHttps=1&redig=3FEC4F2BE86247E8AE3BB965A62CD454&pn=2&first={}&FROM=PERE'.format(i)
        html=requests.get(url,headers=heads)
        soup=BeautifulSoup(html.content,'html.parser')
        job_bt=soup.findAll('h2')
        for i in job_bt:
          time.sleep(3)
          print(i.a.get('href'))
    

      

  • 相关阅读:
    识人高招:六招看清一个人
    让工作变简单的10种技巧
    推销中的五大提问技巧
    给初次签约大学生的忠告
    只要有钱50岁男人也嫁
    我老公一个月赚15000,但是幸福在哪呢?(转载)
    想法简单,生命更宽!
    中国经典到吐血的谎话
    你的思想是你最大的敌人
    完美人生从哪里起步
  • 原文地址:https://www.cnblogs.com/haq5201314/p/8158162.html
Copyright © 2011-2022 走看看