Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib.request
- import requests
- def PageCheck(Link):
- Status = urllib.request.urlopen(Link).getcode()
- SourceNameC = Link.split("//")
- SourceName = SourceNameC[1] + "_source.txt"
- print(SourceName)
- with requests.get(Link) as r:
- with open(SourceName,"wb") as file:
- file = open(SourceName)
- file.write(r.content)
- file.close()
- def main():
- '''
- timestamp = time.time()
- workbook = xlsxwriter.Workbook(os.path.join(os.path.abspath(''), "report" + str(timestamp) + ".xlsx"))
- w1 = workbook.add_worksheet('Groups')
- cell_format = workbook.add_format()
- cell_format.set_border()
- w1.write(0, 0, 'Link', cell_format)
- w1.write(0, 1, 'Status', cell_format)
- row = 1
- linknumber = 1
- num_lines = sum(1 for line in open('links.txt'))
- print(f'Total number of Web Sites to visit: {num_lines}')
- with open(os.path.abspath("links.txt")) as links :
- for line in links :
- row = Scraper(driver, w1, row, line, Category)
- progress(linknumber, num_lines)
- linknumber += 1
- '''
- Link = 'https://www.stackoverflow.com'
- PageCheck(Link)
- main()
Advertisement
Add Comment
Please, Sign In to add comment