From 52f569f5677e0c4dc4e277a9683ebee21771273f Mon Sep 17 00:00:00 2001 From: halleytl <406384832@qq.com> Date: Mon, 9 Feb 2015 00:37:33 +0800 Subject: [PATCH] Add searchPages api Specify the start page to the end of the page --- lib/utils/google.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/utils/google.py b/lib/utils/google.py index b12de7c..e23ef5f 100755 --- a/lib/utils/google.py +++ b/lib/utils/google.py @@ -159,3 +159,17 @@ def search(self, dork): retVal = [urllib.unquote(match.group(1)) for match in re.finditer(DUCKDUCKGO_REGEX, page, re.I | re.S)] return retVal + def searchPages(self, start=1, end=10, filename=None): + """ + This method performs the effective search on Google providing + the google dork and the Google session cookie + Specify the start page to the end of the page + """ + if end < start: end = start + if filename is None: + filename = str(int(time.time())) + "_links.txt" + links = [] + for pageNum in range(start, end+1): + conf.googlePage = pageNum + links.extend(self.search(self, True)) + open(filename, "w").write("\n".join(links))