Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import MySQLdb as sql
- from urllib2 import urlopen
- def get_query(c,x):
- c.execute(x)
- return c.fetchall()
- def get_page(url):
- urlopen(url)
- page = urlopen.read()
- return page
- host='localhost'
- port=3306
- db='bantictest'
- user='root'
- password='insertmehere'
- #Connect to mysql
- sql_connection = sql.connect(host=host,
- user=user,
- passwd=password,
- db=db,
- port=port)
- cursor = sql_connection.cursor()
- #Query
- response = get_query(cursor,"select * from queued")
- url = response[0][2] #select the first result's url
- #Save page
- page = get_page(url)
- webfile = open('./webpage.html', 'w')
- webfile.write(page)
- webfile.close()
- #connection.commit() #If you make any changes to the database, you need this
- connection.close()
Add Comment
Please, Sign In to add comment