fork download
  1. import requests
  2. from bs4 import BeautifulSoup
  3. import time
  4. import schedule
  5.  
  6.  
  7. def access():
  8. url = 'https://f...content-available-to-author-only...e.com/c/marketplace/sales-ads/'
  9. try:
  10. r = requests.get(url)
  11. r.raise_for_status()
  12. open('sales-ads.html', 'wb').write(r.content)
  13. except requests.exceptions.HTTPError as err:
  14. print(err)
  15.  
  16.  
  17. def extraction():
  18. with open('sales-ads.html') as file:
  19. src = file.read()
  20. soup = BeautifulSoup(src, 'lxml')
  21. with open('topics.txt', 'w') as f:
  22. topic_names = soup.find_all('a', class_='title raw-link raw-topic-link')
  23. for item in topic_names:
  24. item_text = item.text
  25. item_url = item.get('href')
  26. print(f"{item_text}: {item_url}", file=f)
  27.  
  28.  
  29. schedule.every(5).seconds.do(access)
  30. schedule.every(5).seconds.do(extraction)
  31.  
  32. while True:
  33. schedule.run_pending()
  34. time.sleep(1)
  35.  
Runtime error #stdin #stdout #stderr 0.39s 34332KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 2, in <module>
ModuleNotFoundError: No module named 'bs4'