Skip to main content

AdvertsAPI

An unofficial API for the community based Irish marketplace, adverts.ie.

Getting Started

Prerequisites

  • Python 3.6 >=

Installing

pip install AdvertsAPI

Dependecies

pip install requests
pip install beautifulsoup4 
pip install mechanize

Imports

import AdvertsAPI
from AdvertsAPI.category import Category
from AdvertsAPI.utils import pretty_json

Available Methods

  • Constructor
  • login
  • get_ad_panel
  • place_offer
  • withdraw_offer
  • full_ad_info
  • search_query
  • logout

Constructor

Default: category=None, county=None, min_price=0, max_price=0, view='grid_view', search=None

advert = AdvertsAPI.AdvertsAPI()

Bike in Dublin: category=Category.SPORTS_FITNESS__BIKES, county='Dublin', min_price=0, max_price=0, view='grid_view', search=None

advert = AdvertsAPI.AdvertsAPI(category=Category.SPORTS_FITNESS__BIKES, county='Dublin')

Mountain bike in Dublin: category=Category.SPORTS_FITNESS__BIKES, county='Dublin', min_price=0, max_price=0, view='grid_view', search='mountain'

advert = AdvertsAPI.AdvertsAPI(category=Category.SPORTS_FITNESS__BIKES, county='Dublin', search='mountain')

ps4 between 100-300 euro: category=Category.CONSOLES_GAMES, county=None, min_price=100, max_price=300, view='grid_view', search='ps4'

advert = AdvertsAPI.AdvertsAPI(category=Category.CONSOLES_GAMES, min_price=100, max_price=300, search='ps4')

free items in Dublin: category=None, county='Dublin', min_price=0, max_price=0, view='grid_view', search=None

advert = AdvertsAPI.AdvertsAPI(county='Dublin')

login

adverts = AdvertsAPI.AdvertsAPI()
adverts.login('username', 'password')

get_ad_panel

NOTE: given the contructor details, it will produce the url for the search.

ads = advert.get_ad_panel()

However you could also pass in the url of the search and it will compute for you.

ads = advert.get_ad_panel('https://www.adverts.ie/for-sale/price_0-0/')

It will return a list of the top 30 ads for that search. The attributes that can be retreived are: price, title, area, county, category and url

for ad in ads:
    print(ad.price)
    print(ad.title)
    print(ad.area)
    print(ad.county)
    print(ad.category)
    print(ad.url)

place_offer

This will place an offer given the url of the ad directly.

Below is an example given a url that is static.

advert.place_offer('ad_url', 100)   

Below will place an offer on the first ad of the ads retreieved above.

advert.place_offer(ads[0].url, 0)

withdraw_offer

Withdraws an offer to a particular ad, given the url. You must have an active offer to withdraw the ad.

advert.withdraw_offer('ad_url')    

full_ad_info

This will return all the information of the ad given the url. The attributes that can be retreived are: title, price, seller, positive, negative, location date_entered, ad_views and description.

advert.full_ad_info('ad_url')
ads = advert.full_ad_info(ads[0].url)

You can retreive the data as follows:

for ad in ads:
    print(ad.title)
    print(ad.price)
    print(ad.seller)
    print(ad.positive)
    print(ad.negative)
    print(ad.location)
    print(ad.date_entered)
    print(ad.ad_views)
    print(ad.description)

search_query

Search query will use the constructor generated url to search for ads.

advert.search_query()

However you can pass a search query to the method and it will return the search results of the query.

# search_query (given query)
ads = advert.search_query('mountain bikes')

Similar to the get_ad_panel method, you can retreive the data as below:

for ad in ads:
    print(ad.title)
    # ...
    print(ad.url)

logout

Not very necessary as it will discard the cookies as the program stops.

adverts.logout()

Usage

For documented examples see examples.py

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Roadmap

See the open issues for a list of proposed features (and known issues).

License

Distributed under the MIT License. See LICENSE for more information.

Metadata

Release files for AdvertsAPI 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for AdvertsAPI 1.0.1
File Size Uploaded Provenance
AdvertsAPI-1.0.1.tar.gz 25.3 kB Without provenance Details

Release files / AdvertsAPI-1.0.1.tar.gz

Download URL AdvertsAPI-1.0.1.tar.gz
Size 25.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3be5ab0f4c7b5deb6fe9354291d1fd489e251294b1540ecc8040795509bf5082
BLAKE2b-256 checksum
How to use checksums
4e203a60e7c3e14d526a6361d2257edee6f06e3dd713c47e238686cb538182b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.0

Security for AdvertsAPI 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page