开发者

Searching a website

开发者 https://www.devze.com 2022-12-20 13:27 出处:网络
import urllib import re import os search = (raw_input(\'[!]Search: \')) site = \"http://www.exploit-db.com/list.php?description=\"+search+\"&author=&platform=&type=&port=&osvdb=&am
import urllib
import re
import os
search = (raw_input('[!]Search: '))
site = "http://www.exploit-db.com/list.php?description="+search+"&author=&platform=&type=&port=&osvdb=&cve="   
print site
source = urllib.urlopen(site).read()
founds = re.findall("href='/exploits/\d+",source)
print "\n[+]Search",len(founds),"Results\n"
if len(founds) >=1:
        for found in founds:
                found = found.rep开发者_如何学JAVAlace("href='","")
                print "http://www.exploit-db.com"+found
else:
        print "\nCouldnt find anything with your search\n"

When I search the exploit-db.com site I only come up with 25 results, how can I make it go to the other page or go pass 25 results.


Easy to check by just visiting the site and looking at the URLs as you manually page: just put right after the ? in the URL page=1& to look at the second page of results, or page=2& to look at the third page, and so forth.

How is this a Python question? It's a (very elementary!) "screen scraping" question.


Apparently the exploit-db.com site doesn't allow extending the page size. You therefore need to "manually" page through the result list by repeating the urllib.urlopen() to get subsequent pages. The URL is the same as the one initially used, plus the &page=n parameter. Attention this n value appears to be 0-based (i.e. &page=1 will give the second page)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号