# [OlxPyApi](https://github.com/Vladislavus1/OlxPyApi)
This package simplifies the extraction of data from OLX websites ([olx.ua](https://www.olx.ua), [olx.pl](https://www.olx.pl), [olx.kz](https://www.olx.kz)). It allows users to programmatically retrieve listings, such as real estate, vehicles, or job offers, directly from OLX.
## How to use it?
First you need to download this package to your computer system by doing this command:
pip install OlxPyApi
Now it's ready to work. In your python file, you'll need to import this package:
from OlxPyApi.parser import OlxParser
You've just imported an ```OlxParser``` class. Then you need to create a class object:
var_name = OlxParser()
```OlxParser``` has one available argument ```-logging=True/False```. Logging is responsible for printing detailed information about parsing process.
To start parsing products from OLX, you'll need to use ```OlxParser``` method called ```get_products(url, amount)``` (where ```amount``` is not necessary argument):
url_example = "https://www.olx.ua/uk/elektronika/"
parser = OlxParser(logging=True)
parser.get_products(url_example)
After you run a code you should see this messages:
Parsing https://www.olx.ua/uk/elektronika/?page=1 (response code: 200) (done)
Parsing https://www.olx.ua/uk/elektronika/?page=2 (response code: 200) (done)
Parsing https://www.olx.ua/uk/elektronika/?page=3 (response code: 200) (done)
...
These messages are saying that parsing ad's urls on each page is done successfully.
After that you'll start to see this messages about "Getting information":
Getting information:
• https://www.olx.ua/d/uk/obyavlenie/libertys-f12-m-b-2l-nova-kavomashina-prodazh-IDWkYXf.html (response code: 200) (done)
• https://www.olx.ua/d/uk/obyavlenie/telefon-huawei-mate-30-pro-8-256gb-dual-IDWDPJw.html (response code: 200) (done)
• https://www.olx.ua/d/uk/obyavlenie/novinka-bezdrotov-navushniki-arpods-3-groskop-chp-huilian-a10-IDUyrz1.html (response code: 200) (done)
• https://www.olx.ua/d/uk/obyavlenie/prodam-aparat-uf-vipromnyuvannya-novator-IDTzLdy.html (response code: 200) (done)
• https://www.olx.ua/d/uk/obyavlenie/blok-zhivlennya-12v-dlya-led-jinbo-jlv-12400kb-IDPSL4Y.html (response code: 200) (done)
• https://www.olx.ua/d/uk/obyavlenie/detskiy-ingalyator-kompressornyy-microlife-neb-400-IDWeuv6 (response code: 200) (done)
...
Now your program is on a phase where main information is picking.
After all that ```get_products``` method will just return a list full of ```OlxAd``` class objects. ```OlxAd``` class objects contains: ```ad_title```, ```ad_price```, ```ad_url```, ```ad_images(list full of ad's images urls)```.
Here's example:
from OlxPyApi.parser import OlxParser
url_example = "https://www.olx.ua/uk/elektronika/"
parser = OlxParser(logging=True)
ads = parser.get_products(url_example)
print(ads[0].ad_title, ads[0].ad_price, ads[0].ad_url, ads[0].ad_images)
Output:
Преміум Якість! BatteryPack MagSafe 5000 mAh/ PowerBank/ Apple 699 грн. https://www.olx.ua/d/uk/obyavlenie/premum-yakst-batterypack-magsafe-5000-mah-powerbank-apple-IDWtbYN.html ['https://ireland.apollo.olxcdn.com:443/v1/files/yx7cd
0u2t2c-UA/image;s=750x1000', 'https://ireland.apollo.olxcdn.com:443/v1/files/grzza7hf5ycj1-UA/image;s=750x1000', 'https://ireland.apollo.olxcdn.com:443/v1/files/oohfrff0t99c1-UA/image;s=750x1000']
As you see everything is working just fine!
## Error logs
In rare cases you can face some errors. Some of them will give you ```error_logs.txt```, **what you need to do with them?**
First, try to fix url or restart the code, if it's not working, please provide ```error_logs.txt``` to me, and I will try to fix it as soon as possible.
## Disclaimer
This project is still in a phase of developing, so the risk of facing errors is really high. Anyway if you face some of them please provide it to [GitHub Issues](https://github.com/Vladislavus1/OlxPyApi/issues), I will be really grateful.
#
Thanks for attention!
Raw data
{
"_id": null,
"home_page": "https://github.com/Vladislavus1/OlxPyApi",
"name": "OlxPyApi",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Vladislavus1",
"author_email": "vlydgames@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/14/70/5b752ea3e9e0eb0ad9c34f118b2d90d2093a6e98eac5095eff2fa26d605e/olxpyapi-0.0.4.tar.gz",
"platform": null,
"description": "# [OlxPyApi](https://github.com/Vladislavus1/OlxPyApi)\r\n\r\nThis package simplifies the extraction of data from OLX websites ([olx.ua](https://www.olx.ua), [olx.pl](https://www.olx.pl), [olx.kz](https://www.olx.kz)). It allows users to programmatically retrieve listings, such as real estate, vehicles, or job offers, directly from OLX.\r\n\r\n## How to use it?\r\n\r\nFirst you need to download this package to your computer system by doing this command:\r\n\r\n pip install OlxPyApi\r\n\r\nNow it's ready to work. In your python file, you'll need to import this package:\r\n\r\n from OlxPyApi.parser import OlxParser\r\n\r\nYou've just imported an ```OlxParser``` class. Then you need to create a class object:\r\n\r\n var_name = OlxParser()\r\n\r\n```OlxParser``` has one available argument ```-logging=True/False```. Logging is responsible for printing detailed information about parsing process.\r\nTo start parsing products from OLX, you'll need to use ```OlxParser``` method called ```get_products(url, amount)``` (where ```amount``` is not necessary argument):\r\n\r\n url_example = \"https://www.olx.ua/uk/elektronika/\"\r\n parser = OlxParser(logging=True)\r\n parser.get_products(url_example)\r\n\r\nAfter you run a code you should see this messages:\r\n\r\n Parsing https://www.olx.ua/uk/elektronika/?page=1 (response code: 200) (done)\r\n Parsing https://www.olx.ua/uk/elektronika/?page=2 (response code: 200) (done)\r\n Parsing https://www.olx.ua/uk/elektronika/?page=3 (response code: 200) (done)\r\n ...\r\n \r\nThese messages are saying that parsing ad's urls on each page is done successfully.\r\nAfter that you'll start to see this messages about \"Getting information\":\r\n\r\n Getting information:\r\n \u2022 https://www.olx.ua/d/uk/obyavlenie/libertys-f12-m-b-2l-nova-kavomashina-prodazh-IDWkYXf.html (response code: 200) (done)\r\n \u2022 https://www.olx.ua/d/uk/obyavlenie/telefon-huawei-mate-30-pro-8-256gb-dual-IDWDPJw.html (response code: 200) (done)\r\n \u2022 https://www.olx.ua/d/uk/obyavlenie/novinka-bezdrotov-navushniki-arpods-3-groskop-chp-huilian-a10-IDUyrz1.html (response code: 200) (done)\r\n \u2022 https://www.olx.ua/d/uk/obyavlenie/prodam-aparat-uf-vipromnyuvannya-novator-IDTzLdy.html (response code: 200) (done)\r\n \u2022 https://www.olx.ua/d/uk/obyavlenie/blok-zhivlennya-12v-dlya-led-jinbo-jlv-12400kb-IDPSL4Y.html (response code: 200) (done)\r\n \u2022 https://www.olx.ua/d/uk/obyavlenie/detskiy-ingalyator-kompressornyy-microlife-neb-400-IDWeuv6 (response code: 200) (done)\r\n ...\r\n\r\nNow your program is on a phase where main information is picking.\r\nAfter all that ```get_products``` method will just return a list full of ```OlxAd``` class objects. ```OlxAd``` class objects contains: ```ad_title```, ```ad_price```, ```ad_url```, ```ad_images(list full of ad's images urls)```.\r\nHere's example:\r\n\r\n from OlxPyApi.parser import OlxParser\r\n \r\n url_example = \"https://www.olx.ua/uk/elektronika/\"\r\n parser = OlxParser(logging=True)\r\n ads = parser.get_products(url_example)\r\n print(ads[0].ad_title, ads[0].ad_price, ads[0].ad_url, ads[0].ad_images)\r\n\r\nOutput:\r\n\r\n \u041f\u0440\u0435\u043c\u0456\u0443\u043c \u042f\u043a\u0456\u0441\u0442\u044c! BatteryPack MagSafe 5000 mAh/ PowerBank/ Apple 699 \u0433\u0440\u043d. https://www.olx.ua/d/uk/obyavlenie/premum-yakst-batterypack-magsafe-5000-mah-powerbank-apple-IDWtbYN.html ['https://ireland.apollo.olxcdn.com:443/v1/files/yx7cd\r\n 0u2t2c-UA/image;s=750x1000', 'https://ireland.apollo.olxcdn.com:443/v1/files/grzza7hf5ycj1-UA/image;s=750x1000', 'https://ireland.apollo.olxcdn.com:443/v1/files/oohfrff0t99c1-UA/image;s=750x1000']\r\n\r\nAs you see everything is working just fine!\r\n\r\n## Error logs\r\n\r\nIn rare cases you can face some errors. Some of them will give you ```error_logs.txt```, **what you need to do with them?**\r\nFirst, try to fix url or restart the code, if it's not working, please provide ```error_logs.txt``` to me, and I will try to fix it as soon as possible.\r\n\r\n## Disclaimer\r\n\r\nThis project is still in a phase of developing, so the risk of facing errors is really high. Anyway if you face some of them please provide it to [GitHub Issues](https://github.com/Vladislavus1/OlxPyApi/issues), I will be really grateful.\r\n\r\n#\r\n\r\nThanks for attention!\r\n",
"bugtrack_url": null,
"license": null,
"summary": "This package simplifies the extraction of data from OLX websites.",
"version": "0.0.4",
"project_urls": {
"Homepage": "https://github.com/Vladislavus1/OlxPyApi"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4d15374b22f407b7d47844b36c41df0a8214e7c1fe1a7cac812fc9bce04516c6",
"md5": "e0c45f1dade35a38f5c96095cae6e9ca",
"sha256": "0e34424e1796e2298b44666f5590a62551590ed6884e19e964d74f6fc02fb10d"
},
"downloads": -1,
"filename": "OlxPyApi-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e0c45f1dade35a38f5c96095cae6e9ca",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5799,
"upload_time": "2024-07-18T08:33:25",
"upload_time_iso_8601": "2024-07-18T08:33:25.908097Z",
"url": "https://files.pythonhosted.org/packages/4d/15/374b22f407b7d47844b36c41df0a8214e7c1fe1a7cac812fc9bce04516c6/OlxPyApi-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "14705b752ea3e9e0eb0ad9c34f118b2d90d2093a6e98eac5095eff2fa26d605e",
"md5": "01eff8de1d7837c0441b892b10732b3e",
"sha256": "bef1cefa291ff87638b33e93fdfd51bae87d865753646d1adad2b9cd58b42440"
},
"downloads": -1,
"filename": "olxpyapi-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "01eff8de1d7837c0441b892b10732b3e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5486,
"upload_time": "2024-07-18T08:33:27",
"upload_time_iso_8601": "2024-07-18T08:33:27.294016Z",
"url": "https://files.pythonhosted.org/packages/14/70/5b752ea3e9e0eb0ad9c34f118b2d90d2093a6e98eac5095eff2fa26d605e/olxpyapi-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-18 08:33:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Vladislavus1",
"github_project": "OlxPyApi",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "olxpyapi"
}