[help][noob]shell window getting stuck

[help][noob]shell window getting stuck

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


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():
    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
        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?
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 = {
data = urllib.urlencode(values)
req = urllib2.Request(url, data.encode())
response = urllib2.urlopen(req)
html = response.read().decode()
we will be moving to python-forum.io on October 1 2016
more details here
User avatar
Posts: 2244
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 4 guests