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

Add query parameters to start_requests' URL #504

Merged
merged 5 commits into from
Sep 23, 2020
Merged

Conversation

romifz
Copy link
Contributor

@romifz romifz commented Sep 22, 2020

ref #470

When a custom parameter is specified twice, Scrapy returns the last specified value only. So, in the example given in #470

-a qs=offset:123456789 -a qs=buyer:xyz

Scrapy would return qs=buyer:xyz. The implementation proposed here can take more than one parameter using , as separator:

-a qs=offset:123456789,buyer:xyz

@romifz romifz requested a review from yolile September 22, 2020 06:26
Copy link
Member

@yolile yolile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@romifz I tested it with Paraguay and it works perfectly!
The only problem is when the value itself has a comma, eg scrapy crawl paraguay_dncp_releases -a qs=buyer.name:"Ministerio de Urbanismo, Vivienda y Habitat" the resulting URL has the parameter with the value just before the comma eg:
https://contrataciones.gov.py/datos/api/v3/doc/search/processes?tipo_fecha=fecha_release&fecha_desde=2010-01-01T00%3A00%3A00&fecha_hasta=2020-09-22T09%3A51%3A01&buyer.name=Ministerio+de+Urbanismo&page=4

and, could you add the new argument's documentation at BaseSpider please?

@romifz
Copy link
Contributor Author

romifz commented Sep 22, 2020

@yolile turns out that scrapy removes the quotes around the parameter values :(

I've modified the method to accept commas escaped using \, so for your example you can use:

scrapy crawl paraguay_dncp_releases -a qs=buyer.name:"Ministerio de Urbanismo\, Vivienda y Habitat"

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

Successfully merging this pull request may close these issues.

None yet

2 participants