Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch offers in categories #7

Open
EliaTolin opened this issue Nov 22, 2023 · 8 comments
Open

Fetch offers in categories #7

EliaTolin opened this issue Nov 22, 2023 · 8 comments

Comments

@EliaTolin
Copy link

Hi,
Is possible fetch offers in the categories?
For example fetch the "Elettronics" (category) offers of the day.

@sushil-rgb
Copy link
Owner

Can you paste the link here, I will look into it and will update you

@EliaTolin
Copy link
Author

For example using the node:

https://www.amazon.it/b?node=2454160031

For example search with categories keywords:
https://www.amazon.it/s?k=offerte+elettronica

I created this web server PAAPI Amazon Webserver but now I need the scraper.

I suggest you to make this more dynamic, for example two new method:

  1. get_category_offers(str category name)

  2. search_products(list[str] keywords)

Without using a url

@sushil-rgb
Copy link
Owner

sushil-rgb commented Nov 23, 2023

Noted. I will look into this and will update you.

@EliaTolin
Copy link
Author

Noted. I will look into this and will update you.

Thanks you, i wait you

@sushil-rgb
Copy link
Owner

hey @EliaTolin, I hope you're doing well. I've created a new .py file called offers.py where I've implemented a function called get_category_offer. This function is designed to scrape offers based on the category name. Here's the snippet::

async def get_category_offer(category_name):
    categ_url = f"https://www.amazon.it/s?k=offerte+{category_name}"
    offers = await Amazon(categ_url, None).export_csv()
    return offers

call and run the method using the below command:

from scrapers.offers import get_category_offer
import asyncio

async def main():
    return await get_category_offer('elettronica')
    
if __name__ == '__main__':
    print(asyncio.run(main()))

can you explain more about the method search_products(list[str] keywords)

@EliaTolin
Copy link
Author

EliaTolin commented Nov 23, 2023

Thank you very much.
After I try it if there is anything I will PR you.

Let me give you a piece of advice.

If you integrate your scraper into another software you are forced to make changes currently because you cannot know the URL based on the country you are operating in.

As you see in the search keywords there is the keyword "offers" which is in Italian.
You have to figure out how to be at most dynamic, that is, independent of the country in which you search for offers and independent of the keywords you enter.

For example you can reason about the Node of categories.

I don't have many ideas but I think it is necessary.

Other advice, currently it is not a library but a series of scraping "examples". It would be nice to make it a library.

Example of use:

amazon_me = AmazonMe(country: CountryAmazon.IT, proxy=True)
#Fetch offers of category
offers_electronics = []
offers_electronics = amazon_me.get_category_offers(CategoryAmazon.electronics)
#Fetch information from asin list
products_asin_list = ['B00PQY7TJA', 'B00PQY7SJA', 'B00PQY7343', '343EHFEJHFE', ........]
products_list = amazon_me.get_product_from_asin(products_asin_list)

I give you this examples for improve your scraper.
This could be better Amazon's scraper on Github.

@sushil-rgb
Copy link
Owner

Thank you for the feedback. The domain name is dynamic for the main scraper, i will try to make it dynamic by using regex pattern for the offer category. I will look into this more later. Thank you for the feedback, i appreciate it.

@EliaTolin
Copy link
Author

Thank you for the feedback. The domain name is dynamic for the main scraper, i will try to make it dynamic by using regex pattern for the offer category. I will look into this more later. Thank you for the feedback, i appreciate it.

Thanks, I suggest you to focus for make this scraper into a library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants