[help][noob]shell window getting stuck

[help][noob]shell window getting stuck

Postby ZingzGone » Fri May 31, 2013 4:59 pm

hello,

i am new to codeing,as i have just finshed the codecademy.com course on python.
i was looking for somthing to get my brain going and decided to creat a code to interact whit thepiratebat.sx and return the torrents name and seed number,as well as a few outer fetures i had in mind..
this is what i got into:
Code: Select all
import urllib2
header = "http://"
def check():
    "try:"
    search_page = "www.thepiratebay.sx"
    results = urllib2.urlopen(header+search_page)
    print results
    print "done checking..."
    search = raw_input("what would you like to search for?:")
    ender = "/search/"+str(search)+"/0/7/0"
    search_results = urllib2.urlopen(header+str(search_page)+ender)
    raw_page = search_results.read()
    print search_results
    print raw_page
       
    """except:
        print "it looks like the pirate bay is not reach-able..."
        """

when i run check() and go throw the search veriable the shell window get stuck...i realy have no idea what is going on..can any of you figure it out?
ZingzGone
 
Posts: 1
Joined: Fri May 31, 2013 4:39 pm

Re: [help][noob]shell window getting stuck

Postby metulburr » Fri May 31, 2013 8:50 pm

for getting the html of the search result:

and i converted it over from python3.x as it looks like you are using 2.x
Code: Select all
import urllib2
import urllib



stdin = raw_input('Search: ')
url = 'http://thepiratebay.sx/s/'

values = {
    'q':stdin
}
data = urllib.urlencode(values)
req = urllib2.Request(url, data.encode())
response = urllib2.urlopen(req)
print(response.geturl())
html = response.read().decode()
print(html)
New Users, Read This
version Python 3.3.2 and 2.7.5, tkinter 8.5, pyqt 4.8.4, pygame 1.9.2 pre
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
User avatar
metulburr
 
Posts: 1103
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY


Return to Networking

Who is online

Users browsing this forum: No registered users and 2 guests