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 Eldorado » Sat Feb 18, 2012 5:52 pm

Got to give us more details when you say it doesn't work, what were the results?

xxx = ok isn't what you should be sending in on the post, do this using Chrome and open developer tools and you will see what was requested and what was sent back... take a look at my post where i gave you the request/response info

Really it looks like you just need to post to this url and you will get the cookie:

Code: Select all
http://www.movie2k.to/xxxcheck.php?confirm=1


The 'confirm=1' is the key, the uri parm seems to just tell it what page to redirect to

Then read the thread rogerthis started about how to save and then retrieve the cookie

Code: Select all
net.http_POST(url)
net.save_cookies(cookie_path)
...
..
net.set_cookies(cookie_path)
net.http_GET(url)
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 5:58 pm

Get everything working, then refine it, but when you do, I think you can save some page pulls if you save those cookies and only use them as needed
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 6:22 pm

Bstrdsmkr wrote:Get everything working, then refine it, but when you do, I think you can save some page pulls if you save those cookies and only use them as needed


OK got it working and seems to give correct info every time.
But still not sure how i would add the save cookie and read cookie.
I know the syntax but not how to use it in the code below.

Code: Select all
from t0mm0.common.net import Net
import urllib2,urllib,re
net = Net()

cat = '53'
page = '1'

url='http://www.movie2k.to/xxx-genre-' + cat + '-' + page + '.html'
net.set_cookies(cookie_path)  #<<<<<<< ?? is this correct
html = net.http_GET(url).content
match = re.findall('<FORM style="display:inline" method=post action="(.+?)">', html)[0]
if match:
     url =  'http://www.movie2k.to//xxxcheck.php?confirm=1&uri=%2 %2Fmovies.php%3Flist%3Dgenre%26id%3D' + cat + '%26site%3D' + page + '%26xxx%3D1'
     data = { 'xxx' : 'ok' }
     html = net.http_POST(url,data).content
     net.save_cookies(cookie_path) #<<<<<<< ?? is this correct


print html


Also just to let you know i have the following working for the Movie2k Addon

Movies A-Z
Movies Categories
Movies Top Movies
Movies Latest
Movies Search

TV Shows Genre
Will be getting the rest working soon.

Movies XXX nearly there , getting correct info just need to be taught how to use cookies and how to implement them

still learning but getting better
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 6:46 pm

just a little update

Code: Select all
cat = '33'
page = '2'

url='http://www.movie2k.to/xxx-genre-' + cat + '-' + page + '.html'
html = net.http_GET(url).content

# << use Search instead otherwise sometimes get a List index error
match = re.search('<FORM style="display:inline" method=post action="(.+?)">', html)

if match:
    url =  'http://www.movie2k.to//xxxcheck.php?confirm=1&uri=%2F%2Fmovies.php%3Flist%3Dgenre%26id%3D' + cat + '%26site%3D' + page + '%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

Re: need help with setting cookie

Postby Eldorado » Sun Feb 19, 2012 12:19 pm

You should be able to simplify it like I said, you only need to post to this address, and you don't need the 'xxx': 'ok' in the header

You may need to put 'confirm': '1' in the header though and take it out of the url

Code: Select all
cookie_path = addon.get_profile()
url = 'http://www.movie2k.to/xxxcheck.php?confirm=1'
net.http_POST(url)
net.save_cookies(cookie_path)


Then later when you need to use the cookie

Code: Select all
net.set_cookies(cookie_path)
net.http_GET(url)
User avatar
Eldorado
DEV
 
Posts: 816
Joined: Wed Jan 04, 2012 12:15 pm

Previous

Return to <dev>GENERAL</dev>



Who is online

Users browsing this forum: No registered users and 0 guests