Python Scrapy spiders that scrapes products and launches data from producthunt.com.
- Item schema for
trending products
andfeatured product launches
defined usingdataclass
- Item pipelines to
normalize
,validate
anddrop
duplicate items. - Download middlewares to random user agents.
-
Clone this repository
-
Install all dependencies
pip install -e .
- To scrape
featured product launches
, run:
scrapy crawl featured-product-launches
- To scrape
trending products
, run:
scrapy crawl trending-products
The scraped data is saved in jsonline
format and may be found at ./data/<spider-name>/date=<scraped-date>
. Where spider-name
is a name of the spider e.g featured-product-launches
and scraped-date
is the date when the spider was runned.
Example, for featured-product-launches
spider runned on 2023-10-24
, then the data may be found at ./data/featured-product-launches/date=2023-10-24
.
- Explore part of the data using
pandas
, use:
import pandas as pd
# replace the date part with your scraping date
# file = "./data/trending-products/date=2023-10-24/part-1.jsonl"
file = "./data/featured-product-launches/date=2023-10-24/part-1.jsonl"
df = pd.read_json(file, lines=True)
df.info()
- To explore all the data using
pandas
, use:
import glob
import pandas as pd
# replace the date part with your scraping date
# files = glob.glob("./data/trending-products/date=2023-10-24/*.jsonl")
files = glob.glob("./data/featured-product-launches/date=2023-10-24/*.jsonl")
dfs = [pd.read_json(file, lines=True) for file in files]
df = pd.concat(dfs, ignore_index=True)
df.info()
It will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. Do not forget to add a bit of test(s) of what value you adding.
lallyelias87@gmail.com, or open a GitHub issue
The featured-product-launches
spider extract the following launch
fields from featured product launches pages:
@dataclass
class ProductLaunchItem:
launch_id: Optional[str] = field(default=None)
launch_slug: Optional[str] = field(default=None)
launch_name: Optional[str] = field(default=None)
launch_tagline: Optional[str] = field(default=None)
launch_description: Optional[str] = field(default=None)
launch_url: Optional[str] = field(default=None)
launch_votes_count: Optional[int] = field(default=None)
launch_comments_count: Optional[int] = field(default=None)
launch_daily_rank: Optional[int] = field(default=None)
launch_weekly_rank: Optional[int] = field(default=None)
launch_created_at: Optional[str] = field(default=None)
launch_featured_at: Optional[str] = field(default=None)
launch_updated_at: Optional[str] = field(default=None)
launch_topics: Optional[List[str]] = field(default=None)
product_id: Optional[str] = field(default=None)
product_name: Optional[str] = field(default=None)
product_url: Optional[str] = field(default=None)
The trending-products
spider extract the following product
fields from trending product pages:
@dataclass
class ProductItem:
product_id: Optional[str] = field(default=None)
product_slug: Optional[str] = field(default=None)
product_name: Optional[str] = field(default=None)
product_tagline: Optional[str] = field(default=None)
product_description: Optional[str] = field(default=None)
product_url: Optional[str] = field(default=None)
product_website_url: Optional[str] = field(default=None)
product_rating: Optional[float] = field(default=None)
product_followers_count: Optional[int] = field(default=None)
product_total_votes_count: Optional[int] = field(default=None)
product_reviewers_count: Optional[int] = field(default=None)
product_reviews_count: Optional[int] = field(default=None)
product_posts_count: Optional[int] = field(default=None)
product_stacks_count: Optional[int] = field(default=None)
product_alternatives_count: Optional[int] = field(default=None)
product_tips_count: Optional[int] = field(default=None)
product_addons_count: Optional[int] = field(default=None)
product_platforms: Optional[List[str]] = field(default=None)
product_categories: Optional[List[str]] = field(default=None)
product_topics: Optional[List[str]] = field(default=None)
The MIT License (MIT)
Copyright (c) lykmapipo & Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.