-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
756cfb2
commit fd3e7c6
Showing
7 changed files
with
37 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import requests | ||
from bs4 import BeautifulSoup | ||
|
||
|
||
def request_status_code(url): | ||
try: | ||
response = requests.get(url) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
from googlesearch import search | ||
import logging | ||
|
||
def rank(domain, query, lang = 'en', tld = 'com'): | ||
|
||
def rank(domain, query, lang='en', tld='com'): | ||
my_results_list = [] | ||
lang = lang | ||
tld = tld | ||
if lang is None: | ||
lang = 'en' | ||
if tld is None: | ||
tld = 'com' | ||
tld = 'com' | ||
|
||
for i in search(query, # The query you want to run | ||
tld = 'com', # The top level domain | ||
lang = 'en', # The language | ||
num = 10, # Number of results per page | ||
start = 0, # First result to retrieve | ||
stop = 100, # Last result to retrieve | ||
pause = 2.0, # Lapse between HTTP requests | ||
): | ||
tld='com', # The top level domain | ||
lang='en', # The language | ||
num=10, # Number of results per page | ||
start=0, # First result to retrieve | ||
stop=100, # Last result to retrieve | ||
pause=2.0, # Lapse between HTTP requests | ||
): | ||
my_results_list.append(i) | ||
logging.debug(str(my_results_list.index(i)) + ": " + str(i)) | ||
if domain in i: | ||
return {"pos": my_results_list.index(i) + 1, "url": i} | ||
return {"pos": -1, "url": None} | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', level=logging.DEBUG, datefmt='%m/%d/%Y %I:%M:%S %p') | ||
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', | ||
level=logging.DEBUG, datefmt='%m/%d/%Y %I:%M:%S %p') | ||
|
||
print(rank("primates.dev", "parse xml response python")) | ||
|