Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests as r
- import subprocess as sub
- #http://www.jeuxvideo.com/forums/0-51-0-1-0-1-0-blabla-18-25-ans.htm
- def get(url):
- return r.get(url).content.decode('utf-8')
- def save(filename, data):
- with open(filename, 'a') as f:
- f.write(data)
- def get_clip():
- p = sub.Popen(['xclip','-selection', 'clipboard', '-o'], stdout=sub.PIPE)
- retcode = p.wait()
- return p.stdout.read()
- domain = "http://www.jeuxvideo.com"
- url = "http://www.jeuxvideo.com/profil/"
- fav = "?mode=favoris"
- user = get_clip().decode('utf-8').lower()
- if not 'http://' in user:
- user = user.split('\n')[0].strip()
- else:
- user = user.split(url)[1].split('?')[0]
- url = url + user + fav
- print(url)
- start_tag = '<li><a href="//'
- data = str(get(url)).split(start_tag)
- log = []
- title = []
- for item in data[1:]:
- temp = item.split('</a></li>')[0]
- lien, titre = temp.split('">')
- titre = titre.replace(''',"'").replace('"',"'")
- print(titre)
- log.append(lien + " " + titre)
- temp = "<tr><td><a target='_blank' href='http://" + lien + "' >" + titre + "</a></td></tr>"
- title.append(temp)
- print(len(title), "topic trouvés" if len(title)>1 else "topic trouvé")
- if len(title) and input('\nWanna save ? '):
- title = '\n'.join(title) + '\n'
- save('fav.html', title)
- save('historique.log', '\n'.join(log)+ '\n')
- import ftplib
- #Use ftplib.FTP_TLS instead if you FTP host requires TLS.
- session = ftplib.FTP('ftp.website.fr','username','password')
- session.cwd('www/jvc')
- file = open('fav.html','rb') # file to send
- session.storbinary('STOR index.html', file) # send the file
- file.close() # close file and FTP
- session.quit()
- print('done')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement