Guest User

Untitled

a guest
Jun 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. import urllib.request
  2. import requests
  3.  
  4. def PageCheck(Link):
  5. Status = urllib.request.urlopen(Link).getcode()
  6. SourceNameC = Link.split("//")
  7. SourceName = SourceNameC[1] + "_source.txt"
  8. print(SourceName)
  9. with requests.get(Link) as r:
  10.  
  11. with open(SourceName,"wb") as file:
  12. file = open(SourceName)
  13. file.write(r.content)
  14.  
  15. file.close()
  16.  
  17. def main():
  18. '''
  19. timestamp = time.time()
  20. workbook = xlsxwriter.Workbook(os.path.join(os.path.abspath(''), "report" + str(timestamp) + ".xlsx"))
  21. w1 = workbook.add_worksheet('Groups')
  22. cell_format = workbook.add_format()
  23. cell_format.set_border()
  24. w1.write(0, 0, 'Link', cell_format)
  25.  
  26. w1.write(0, 1, 'Status', cell_format)
  27. row = 1
  28. linknumber = 1
  29. num_lines = sum(1 for line in open('links.txt'))
  30. print(f'Total number of Web Sites to visit: {num_lines}')
  31. with open(os.path.abspath("links.txt")) as links :
  32. for line in links :
  33. row = Scraper(driver, w1, row, line, Category)
  34. progress(linknumber, num_lines)
  35. linknumber += 1
  36. '''
  37. Link = 'https://www.stackoverflow.com'
  38. PageCheck(Link)
  39. main()
Advertisement
Add Comment
Please, Sign In to add comment