An unofficial API for the community based Irish marketplace, adverts.ie
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file AdvertsAPI-1.0.1.tar.gz
.
File metadata
- Download URL: AdvertsAPI-1.0.1.tar.gz
- Upload date:
- Size: 25.3 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3be5ab0f4c7b5deb6fe9354291d1fd489e251294b1540ecc8040795509bf5082 |
|
MD5 | c791fafbd9998b1ff846cd4adf9a77a1 |
|
BLAKE2b-256 | 4e203a60e7c3e14d526a6361d2257edee6f06e3dd713c47e238686cb538182b4 |