Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # import libraries
- from urllib.request import urlopen, Request
- from bs4 import BeautifulSoup
- # Deathsnacks url including Warframe alert information
- wf_quote = 'https://deathsnacks.com/wf/'
- # Header to be able to access the server as a user
- hdr = {'User-Agent': 'Mozilla/5.0'}
- req = Request(wf_quote, headers=hdr)
- # Open the page
- wf_page = urlopen(req)
- # Parse the HTML into an object
- soup = BeautifulSoup(wf_page, 'html.parser')
- # Find the contents of the alert table using what I had found to be unique
- alert_table = soup.find_all('li', class_='list-group-item')
- # Open a file for use to store alert data.
- f = open("alert_data.txt", "w")
- # Read through the search results, grabbing the first 3 elements, since there are only ever 3 alerts
- count = 1
- for x in alert_table:
- # Write to that file using indents
- f.write(x.prettify())
- # Check if the current Alert is 3, if so then break out the loop and end the script
- # If not, add to the counter to write the next alert.
- if count == 3:
- break
- count += 1
- # Close the file.
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement