Skip to content

Instantly share code, notes, and snippets.

@eshem
Created September 25, 2016 22:05
Show Gist options
  • Save eshem/b7ce3f6da72959a3b0f36e2a2910af1e to your computer and use it in GitHub Desktop.
Save eshem/b7ce3f6da72959a3b0f36e2a2910af1e to your computer and use it in GitHub Desktop.
## Developed by @SoleWingSneaks
## Uses the Tellegram API to send send the product link when found
## User must supply very own server, botkey and chatid
## Read up on the app and how to use their API and get your botkey and chatid here https://core.telegram.org/
import requests
from bs4 import BeautifulSoup
from threading import Thread
def message(bot_key, chat_id, txt):
message_link = 'https://api.telegram.org/bot%s/sendMessage?chat_id=%s&text=%s' % bot_key, chat_id, txt
send = requests.get(message_link)
def scrape(website, link_list):
link_list[:] = []
sitemap = requests.get(website)
soup = BeautifulSoup(sitemap.content, 'html.parser')
links = soup.find_all('url')
for link in links:
link_list.append(link)
def monitor(website, bot_key, chat_id):
inital = []
current = []
scrape(website, inital)
while 1:
scrape(website, current)
if initial != current :
for url in range(0,len(initial)):
if current[url] not in initial:
message(bot_key, chat_id, (website+current[url].loc.text))
scrape(website,initial)
else :
scrape(website, initial)
def main():
t1 = Thread(target = monitor, args = ('Sitemap link', 'insert your own bot key', 'insert the chat id'))
t1.start()
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment