Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .actor/actor.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"name": "RexScraper",
"version": "0.1",
"buildTag": "latest",
"environmentVariables": {}
"environmentVariables": {},
"storages": {
"dataset": "./dataset_schema.json"
}
}
52 changes: 52 additions & 0 deletions .actor/dataset_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"actorSpecification": 1,
"views": {
"overview": {
"title": "Overview",
"transformation": {
"fields": [
"sku",
"name",
"category",
"price",
"imageUrl",
"description",
"url"
]
},
"display": {
"component": "table",
"properties": {
"sku": {
"label": "sku",
"format": "text"
},
"name": {
"label": "name",
"format": "text"
},
"category": {
"label": "category",
"format": "text"
},
"price": {
"label": "price",
"format": "text"
},
"imageUrl": {
"label": "image",
"format": "image"
},
"description": {
"label": "description",
"format": "text"
},
"url": {
"label": "url",
"format": "link"
}
}
}
}
}
}
5 changes: 3 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def get_product_details(context: BeautifulSoupCrawlingContext, category: str) ->
"""Scrape details of specific product."""
soup = context.soup
details = {
'sku': soup.find('span', {'itemprop': 'name'}).text,
'name': soup.find('span', {'itemprop': 'name'}).text,
'sku': soup.find('div', {'itemprop': 'sku'}).text,
'category': category,
'price': soup.find('div', 'product-info-price').find('span', 'price').text,
'imageUrl': soup.select('.gallery-placeholder__image')[0]['src'].split('?')[0],
Expand Down Expand Up @@ -70,7 +71,7 @@ async def main() -> None:
async with Actor:
actor_input = await Actor.get_input() or {}
max_requests_per_crawl = actor_input.get('max_requests_per_crawl', 30)
desired_categories = {category.lower() for category in actor_input.get('categories', [])}
desired_categories = {category.lower() for category in actor_input.get('desired_categories', [])}
include_keywords = {word.lower() for word in actor_input.get('include_keywords', [])}
exclude_keywords = {word.lower() for word in actor_input.get('exclude_keywords', [])}
Actor.log.info(f'{desired_categories=}, {include_keywords=},{exclude_keywords=},{max_requests_per_crawl=}')
Expand Down
Loading