Code Monkey home page Code Monkey logo

py-bricklink's People

Contributors

robbietjuh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

py-bricklink's Issues

Trying to use the API for the first time: SERVER_ERROR

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!

Licensing

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!

Re-uploading a backed up inventory

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

OAUTH Invalid Signature when pulling price info

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!

How to make a request?

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?

  1. I place the 'BrickLink' folder in 'Lib'
  2. I replace the values in the init with my API data from BrickLink
  3. I run api.py

Is this the right approach or do I have to write another program to make the actual request?

Any help is appreciated!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.