Last active
October 13, 2017 07:23
-
-
Save WakeupTsai/de526b73c44cb3713e951a2100d57095 to your computer and use it in GitHub Desktop.
[books2readmoo] Parse the books web and import into readmoo #webcrawler #crawler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parse the books web and import into readmoo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#coding:utf-8 | |
import urllib, urllib2, cookielib | |
import json | |
cj = cookielib.CookieJar() | |
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) | |
token = opener.open('https://member.readmoo.com/login/').info().getheader('set-cookie')[11:47] | |
login_data = urllib.urlencode({ | |
'email' : '', | |
'password' : ''}) | |
opener.addheaders.append(('x-xsrf-token', token)) | |
response = opener.open('https://member.readmoo.com/login/', login_data) | |
book_info = urllib.urlencode({ | |
'isbn' : '', | |
'title' : '', | |
'author_name' : '', | |
'publisher' : '', | |
'pages' : '', | |
'language' : '' | |
}) | |
resp = opener.open('https://share.readmoo.com/book/add',book_info) | |
print resp.read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment