Skip to content

Instantly share code, notes, and snippets.

@ebi3102
Last active March 8, 2021 02:48
Show Gist options
  • Save ebi3102/07470120b8370ac393048fa9cf5ca5a6 to your computer and use it in GitHub Desktop.
Save ebi3102/07470120b8370ac393048fa9cf5ca5a6 to your computer and use it in GitHub Desktop.
import threading
"""
it returns the price of gold per unit of mesghal form http://tgju.org
"""
def scraper():
# import libraries
import urllib.request
from bs4 import BeautifulSoup
# specify the url
quote_page = 'https://www.tgju.org/profile/mesghal'
# query the website and return the html to the variable 'page'
page = urllib.request.urlopen(quote_page)
# parse the html using beautiful soup and store in the variable 'soup'
soup = BeautifulSoup(page, 'html.parser')
# find the span tag with data-col attribute
name_box = soup.find("span", {"data-col": "info.last_trade.PDrCotVal"})
# define variable for where we'll store the name of our stock
name = name_box.text.strip() # strip() is used to remove starting and trailing
return name
def timer():
threading.Timer(5.0, timer).start()
print(scraper())
timer()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment