Board index   FAQ   Search  
  Login

PLEASE VISIT OUR NEW FORUMS FOR FUTURE POSTING. THIS FORUM REMAINS ONLINE FOR ARCHIVE PURPOSES ONLY.

Board index <dev>GENERAL</dev>

need help with setting cookie

This is or all devs of all types. For devs, by devs.

Re: need help with setting cookie

Postby k_zeon » Sat Feb 18, 2012 1:53 pm

rogerthis wrote:First thing, you need to add load of print statements to your code so you can see what is happening
Second thing this site has major encoding issues. project free tv has as well, so it would be worth having a look at that code.

No cookies are needed, and you don't need the post request either.
Here is working code for getting pasted the 18 + button
http://pastebin.com/VdC4gXjS

Basically, you just call another url with "confirm=1" added in the middle and it works.


Hi Roger. thanks for the reply. On initial test it loaded the page correctly.
However this is just one page of 25 link at a time.

if you take the main_url = 'http://www.movie2k.to/xxx-genre-53-1.html' the number 53 represents a Genre, each Genre has a Number. and the number 1 represent the page number.
Now if i change some of these ie 53 to 40 and 1 to 3 or 4 or 5 etc the page does not load with correct info.
When i check in my web browser the page asks the user to press button to say they are over 18 and then the page reloads with correct info ie. a list of links

i use the code below to check in Idle as it easier. Some the pages load but most dont.
Hope you can help. Its been driving me nuts since last night.

Code: Select all
from t0mm0.common.net import Net
import urllib2,urllib,re
net = Net()
site_url = 'http://www.movie2k.to/'
url='http://www.movie2k.to/xxx-genre-40-3.html'
try:
    #addon.log_debug('fetching %s' % url)
    #url = addon.queries['url']
    print 'url: '+url
    post_url = net.http_GET(url).get_url()
    print 'post_url: '+post_url
    html = net.http_GET(post_url).content
    html = html.encode("utf-8")
    #print html
    confirm = re.findall('<FORM style="display:inline" method=post action="(.+?)">', html)[0]
    print site_url+confirm
    post_url = net.http_GET(site_url+confirm).get_url()
    print 'post_url: '+post_url
    html = net.http_GET(site_url+confirm).content
    html = html.encode("utf-8")
except urllib2.URLError, e:
    html = ''
       
print html


Also sometimes i get
IndexError: list index out of range
with confirm = re.findall('<FORM style="display:inline" method=post action="(.+?)">', html)[0]
as it does not find this info
k_zeon
INVOLVED USER
 
Posts: 147
Joined: Wed Jan 25, 2012 9:10 am

Re: need help with setting cookie

Postby rogerthis » Sat Feb 18, 2012 2:25 pm

How did you import t0mm0.common so you can use it in idle?
User avatar
rogerthis
DEV
 
Posts: 216
Joined: Wed Jan 04, 2012 1:24 pm
Location: Connacht

Re: need help with setting cookie

Postby k_zeon » Sat Feb 18, 2012 2:32 pm

if you take the folder t0mm0 and place inside the lib folder on pc.

C:\Python27\Lib\t0mm0
common
__init__.py

then just run the code i gave.

I couldn't beleive it was that easy myself.
k_zeon
INVOLVED USER
 
Posts: 147
Joined: Wed Jan 25, 2012 9:10 am

Re: need help with setting cookie

Postby Eldorado » Sat Feb 18, 2012 4:13 pm

I don't think you need to worry about the cookie

Have you tried simply adding &xxx=1 to the end of the url? This url seems to work ok for me..

Code: Select all
http://www.movie2k.to//movies.php?list=genre&id=53&site=1&xxx=1


Edit.. ah never mind, cookie started kicking in again :)

What if you did a post to mimic the 'I am 18 years old' button?

Code: Select all
<FORM style="display:inline" method=post action="xxxcheck.php?confirm=1&uri=%2F%2Fmovies.php%3Flist%3Dgenre%26id%3D53%26site%3D1%26xxx%3D1">
        <INPUT type="submit" value="I'm 18+ years old!" onClick="loadpopunder();">
    </FORM>


It looks like the response gives you what you need:

Code: Select all
Request URL:http://www.movie2k.to//xxxcheck.php?confirm=1&uri=%2F%2Fmovies.php%3Flist%3Dgenre%26id%3D53%26site%3D1%26xxx%3D1
Request Method:POST
Status Code:302 Moved Temporarily
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:0
Content-Type:application/x-www-form-urlencoded
Cookie:lang=en; wigetmedia_movie2k=1; CSID=b7054cd3eddf0d0e98251d9dfbf6d682; PHPSESSID=4carh63p302mkksku69aq0cka6; xxx2=ok; __utma=98492163.2135147862.1329595454.1329595454.1329595454.1; __utmb=98492163.25.10.1329595454; __utmc=98492163; __utmz=98492163.1329595454.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Host:www.movie2k.to
Origin:http://www.movie2k.to
Referer:http://www.movie2k.to//xxxcheck.php?uri=%2F%2Fmovies.php%3Flist%3Dgenre%26id%3D53%26site%3D1%26xxx%3D1
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11
Query String Parametersview URL encoded
confirm:1
uri://movies.php?list=genre&id=53&site=1&xxx=1
Response Headersview source
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html
Date:Sat, 18 Feb 2012 20:19:38 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Location:http://www.movie2k.to//movies.php?list=genre&id=53&site=1&xxx=1
Pragma:no-cache
Server:nginx/1.0.6
Set-Cookie:xxx2=ok; expires=Sun, 19-Feb-2012 20:21:55 GMT; path=/; domain=.movie2k.to
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Powered-By:PHP/5.3.10-1~dotdeb.1
User avatar
Eldorado
DEV
 
Posts: 816
Joined: Wed Jan 04, 2012 12:15 pm

Re: need help with setting cookie

Postby k_zeon » Sat Feb 18, 2012 4:21 pm

Eldorado wrote:I don't think you need to worry about the cookie

Have you tried simply adding &xxx=1 to the end of the url? This url seems to work ok for me..

Code: Select all
http://www.movie2k.to//movies.php?list=genre&id=53&site=1&xxx=1


Edit.. ah never mind, cookie started kicking in again :)


Hi Eldorado.

Nope doesn't work. If it did work for you then try a diffent genre and page number
eventually the page returned wont have any links, it will have basic page + the bit where you have to click a button to continue

Code: Select all
url = 'http://www.movie2k.to//movies.php?list=genre&id=53&site=1&xxx=1'
html = net.http_GET(url).content
print html
k_zeon
INVOLVED USER
 
Posts: 147
Joined: Wed Jan 25, 2012 9:10 am

Re: need help with setting cookie

Postby k_zeon » Sat Feb 18, 2012 4:21 pm

tks Eldorado , been trying for 2 days to crack this. glad its not just me then
k_zeon
INVOLVED USER
 
Posts: 147
Joined: Wed Jan 25, 2012 9:10 am

Re: need help with setting cookie

Postby Eldorado » Sat Feb 18, 2012 4:25 pm

k_zeon wrote:tks Eldorado , been trying for 2 days to crack this. glad its not just me then


I was still editing while you replied, have you tried posting to that url and grabbing the response? That sounds like it should do it..

Do a http_POST(url) to that address that the button uses, the response will have the cookies you need.. then run save_cookies()
User avatar
Eldorado
DEV
 
Posts: 816
Joined: Wed Jan 04, 2012 12:15 pm

Re: need help with setting cookie

Postby Bstrdsmkr » Sat Feb 18, 2012 4:46 pm

Like Eldorado said, posting to the same address as the button should give you the appropriate cookies in the response, so you can just save_cookies() them. Just remember to include the form data in your post
Bstrdsmkr
XBMC HUB TEAM
 
Posts: 1876
Joined: Mon Jan 16, 2012 10:30 pm

Re: need help with setting cookie

Postby k_zeon » Sat Feb 18, 2012 5:39 pm

just tried

url = 'http://www.movie2k.to//movies.php?list=genre&id=53&site=1&xxx=1'
data = { 'xxx' : 'ok' }
html = net.http_POST(url,data).content

but does not work
what am i missing
k_zeon
INVOLVED USER
 
Posts: 147
Joined: Wed Jan 25, 2012 9:10 am

Re: need help with setting cookie

Postby k_zeon » Sat Feb 18, 2012 5:41 pm

getting somewhere now. below seems to have given the correct page

Code: Select all
url = 'http://www.movie2k.to/xxxcheck.php?confirm=1&uri=%2F%2Fmovies.php%3Flist%3Dgenre%26id%3D30%26site%3D7%26xxx%3D1'
data = { 'xxx' : 'ok' }
html = net.http_POST(url,data).content
print html
k_zeon
INVOLVED USER
 
Posts: 147
Joined: Wed Jan 25, 2012 9:10 am

PreviousNext

Return to <dev>GENERAL</dev>



Who is online

Users browsing this forum: No registered users and 1 guest