robbietjuh / py-bricklink Goto Github PK
View Code? Open in Web Editor NEWPython Bricklink API
Python Bricklink API
The two commands I've tried so far:
api.catalog.getItem(item_no=30153)
api.catalog.getPriceGuide(item_type='SET', item_no='colsim-2', guide_type='sold', new_or_used='N')
And the error I get:
Traceback (most recent call last):
File "app.py", line 20, in <module>
stat = pr.api.catalog.getPriceGuide(item_type='SET', item_no='colsim-2', guide_type='sold', new_or_used='N')
File "/home/nathan/ProgrammingProjects/bricklink-tools/bricklink/methods.py", line 189, in getPriceGuide
return self.client.get(self.URL_CATALOG_PRICE_GUIDE.format(type=item_type, no=item_no), params)
File "/home/nathan/ProgrammingProjects/bricklink-tools/bricklink/api.py", line 63, in get
return self.request('GET', url, params)
File "/home/nathan/ProgrammingProjects/bricklink-tools/bricklink/api.py", line 60, in request
return self.processResponse(response, method, url, params)
File "/home/nathan/ProgrammingProjects/bricklink-tools/bricklink/api.py", line 42, in processResponse
elif meta['message'] == 'BAD_OAUTH_REQUEST': raise BricklinkBadOauthRequestException(meta['description'])
bricklink.exceptions.BricklinkBadOauthRequestException: SERVER_ERROR: Server Error
I've searched the Internet to try to figure it out, but can't find anyone talking about this specific error.
Thanks for making this tool available!
Hi, I'm curious what license this library is using? Apache 2.0? I'd like to use it in another open source project I'm doing, but wanted to make sure.
Thanks!
Hi Robbie,
it's me again. Since you know BrickLink and Python very well, I wanted to ask you if you would be so kind to look into the following issue, eventhough it is not really related to your module:
I am looking for an inventory backup of our shop that can be reuploaded to BrickLink, but getting the .json file from the GET /inventories request into the right xml-standard is quite hard. Since there is an inventory download on Bricklink in the right format, I changed my approach from using the API to scraping... if that is the correct term. :)
So far I managed to login successfully under Python 2.7 using requests with the following code:
import requests
with requests.Session() as c:
url = 'https://www.bricklink.com/login.asp?logInTo=&logFolder=p&logSub=w'
USERNAME = '.....'
PASSWORD = '.....'
c.get(url)
login_data = dict(frmUsername=USERNAME, frmPassword=PASSWORD, a='a')
c.post(url, data=login_data, headers={"Referer": "https://www.bricklink.com/login.asp"})
page = c.get('http://www.bricklink.com/invExcel.asp')
print page.content
I end up at the get page, so I guess the login was successfull. Then I wanted to make a similar request to the form on BrickLink witch gives out the file download I need as a response. However, this post request does not work with form data only, probably due to cookie protection!? Here is what Chrome shows me when I send the post request manually:
General
Remote Address:
54.208.56.110:80
Request URL:
http://www.bricklink.com/invExcelFinal.asp?
Request Method:
POST
Status Code:
200 OK
Response Headersview source
Cache-Control:
private
Connection:
close
Content-Disposition:
attachment; filename=invxml.txt;
Content-Type:
text/xml;charset=UTF-8
Date:
Fri, 17 Apr 2015 01:49:05 GMT
Server:
Microsoft-IIS/7.5
Set-Cookie:
lngOpt=1; expires=Sun, 17-May-2015 01:49:04 GMT; path=/
Set-Cookie:
isCountryID=DE; path=/
Set-Cookie:
BLalertCnt=1184; domain=bricklink.com; path=/
Set-Cookie:
BLdiscussFlag=; domain=bricklink.com; path=/
Set-Cookie:
viewCurrencyID=2; path=/
X-Powered-By:
ASP.NET
Request Headersview source
Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:
gzip, deflate
Accept-Language:
de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:
max-age=0
Connection:
keep-alive
Content-Length:
111
Content-Type:
application/x-www-form-urlencoded
Cookie:
catalogView=cView=1; is_returning=1; xxxx=xxxx; _gat=1; isPw=; isType=; isLoggedInAs=; rememberMe=; isUserID=; BLAUTHACCOUNT=202103; _ga=GA1.2.1196042763.1422431124; lngOpt=1; isCountryID=DE; BLalertCnt=1184; BLdiscussFlag=; viewCurrencyID=2
Host:
www.bricklink.com
Origin:
http://www.bricklink.com
Referer:
http://www.bricklink.com/invExcel.asp
User-Agent:
Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36
Form Dataview sourceview URL encoded
dialogBox:
viewType:
x
invStock:
Y
invQtyMin:
0
invQtyMax:
0
itemType:
catID:
colorID:
invNew:
itemYear:
q:
rmkTp:
W
How should I proceed? Do I have to get other modules like cookielib or something like that?
thx in advance and best regards,
Dennis
I'm in a similar situation to debe13 as listed in issue #2 - New to Python and the BL api.
I've taken the examples shown in the previous issue, and am trying to obtain price data. The problem I have is that I have expanded the example to have three lines/calls to the api, the results of which will be displayed/saved and otherwise manipulated later:
inventory = api.inventory.getInventories()
itemdets = api.catalog.getItem(item_type='SET', item_no='colsim-2')
prices = api.catalog.getPriceGuide(item_type='SET', item_no='colsim-2')
The first two calls work fine, but the getPriceGuide call fails with an error:
Traceback (most recent call last):
File "C:\Users\alan\Dropbox\Python\BL\getapi.py", line 19, in
prices = api.catalog.getPriceGuide(item_type='SET', item_no='colsim-2')
File "C:\Users\alan\Dropbox\Python\BL\bricklink\methods.py", line 189, in getPriceGuide
return self.client.get(self.URL_CATALOG_PRICE_GUIDE.format(type=item_type, no=item_no), params)
File "C:\Users\alan\Dropbox\Python\BL\bricklink\api.py", line 64, in get
return self.request('GET', url, params)
File "C:\Users\alan\Dropbox\Python\BL\bricklink\api.py", line 61, in request
return self.processResponse(response, method, url, params)
File "C:\Users\alan\Dropbox\Python\BL\bricklink\api.py", line 43, in processResponse
elif meta['message'] == 'BAD_OAUTH_REQUEST': raise BricklinkBadOauthRequestException(meta['description'])
BricklinkBadOauthRequestException: SIGNATURE_INVALID: Invalid Signature
I'm not quite sure why this is happening - I'm using the same parameters for each call! Any advice or guidance would be much appreciated by this newbie!
Hi,
I am new to python and I want to use this module to connect to the BrickLink API. In my specific example I want to make a GET /inventories request. How does that work exactly?
Is this the right approach or do I have to write another program to make the actual request?
Any help is appreciated!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.