Skip to main content

A package used to fetch public information about trophies from PSN.

Project description

TrophyFetcher provides a way to extract information from the PSN Public Trophies website. It uses Selenium and PhantomJS to access the website and scrape it, therefore, there are private information that TrophyFetcher is not able to extract (everything that is not on the website).

Installation

You need to install PhantomJS to be able to use TrophyFetcher. There are multiple ways to install it, such as with npm.

$ npm install -g phantomjs

If you do not have npm installed and do not want to install it, I recommend checking their website to look for other alternatives.

To install TrophyFetcher itself, simply do:

$ pip install trophyfetcher

Remember that you need Selenium as well, but pip will most likely that care of that for you.

Tutorial

All you need to do is create a TrophyFetcher object and call the user_info method passing the username of the user you want to extract information from.

from trophyfetcher import TrophyFetcher

tf = TrophyFetcher()
extracted_info = tf.user_info('username')

TrophyFetcher will automatically log errors in a file called trophyfetcher_log.txt, but you can turn that off by doing:

from trophyfetcher import TrophyFetcher

tf = TrophyFetcher()
tf.logging_option(False)
extracted_info = tf.user_info('username')

If a problem occurs and Selenium is not able to locate elements on the page, TrophyFetcher will raise a TimeoutException and log (if logging is enabled) which element caused the error. If that happens, it is most likely due to slow connection or a problem with the website, since TrophyFetcher will wait until 30 seconds before it raises the TimeoutException.

Finally, if everything goes well, you will receive an object in the following format (JSON):

{
    "avatar_url": "https://avatar_example.png",
    "bronze_trophies": "0",
    "games_info": [{
        "bronze_trophies": "0",
        "gold_trophies": "0",
        "img_url": "https://game_example.png",
        "name": "example",
        "platform": "example platform",
        "platinum_trophies": "0",
        "progress": "0%",
        "silver_trophies": "0"
    }],
    "gold_trophies": "0",
    "level": "0",
    "level_progress": "0",
    "platinum_trophies": "0",
    "silver_trophies": "0",
    "trophies": "0"
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trophyfetcher-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trophyfetcher-0.1.0-py2-none-any.whl (23.6 kB view details)

Uploaded Python 2

File details

Details for the file trophyfetcher-0.1.0.tar.gz.

File metadata

  • Download URL: trophyfetcher-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for trophyfetcher-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4e3f6de8704530ba4cc1b59595ac7976952d26cd30f9bfaeed92b8c203ad3963
MD5 4255b2839d0069f0ed3953d646d0101e
BLAKE2b-256 365243189a40f9cb5672779dcfbab430dbe1fe082095f12cb97ce417cf3eb738

See more details on using hashes here.

File details

Details for the file trophyfetcher-0.1.0-py2-none-any.whl.

File metadata

File hashes

Hashes for trophyfetcher-0.1.0-py2-none-any.whl
Algorithm Hash digest
SHA256 f415e6022a8914e439c17226d67136945d297fa6eecfd6488c46fb26cef2098f
MD5 c101e0955ac6df9381af83570fd4c844
BLAKE2b-256 ce26bf75941451b7f605799f77eb86d6ae8e29d213e87a71ffee142f35ad8be7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page