Problem
When I use the search function on Registry with the host "https://crates.io"
Steps
- A new rust project
- Create a registry with Registry::new()
- Use the search function
Possible Solution(s)
Notes
This is what my code is
use crates_io::*; fn main() { let mut crates = Registry::new(String::from("https://crates.io"), None); let mut query = crates.search("clap",10).unwrap(); }
Also, this is the panic message:
thread 'main' panicked at 'called Result::unwrap() on an Err value: failed to get a 200 OK response, got 403
headers:
HTTP/2 403
content-length: 667
server: nginx
date: Sun, 03 Jan 2021 15:32:18 GMT
strict-transport-security: max-age=31536000
via: 1.1 vegur, 1.1 9349ae4f82564896b96f5303b030d189.cloudfront.net (CloudFront)
x-cache: Error from cloudfront
x-amz-cf-pop: ZRH50-C1
x-amz-cf-id: Y5DRl7OZ_nNIvAFIOkpmCig2tYjyWmfNPCX6MmAvnIVwrA0Q5aWJrA==
body:
We require that all requests include a User-Agent header. To allow us to determine the impact your bot has on our service, we ask that your user agent actually identify your bot, and not just report the HTTP client library you're using. Including contact information will also reduce the chance that we will need to take action against your bot.
Bad:
User-Agent: reqwest/0.9.1
Better:
User-Agent: my_crawler
Best:
User-Agent: my_crawler (my_crawler.com/info)
User-Agent: my_crawler (help@my_crawler.com)
If you believe you've received this message in error, please email help@crates.io and include the request id b8cb398a-10fb-4152-99f4-5e1a74571b02.
Output of cargo version:
cargo 1.47.0 (f3c7e06 2020-08-28)
macos big sur
x64
Problem
When I use the search function on Registry with the host "https://crates.io"
Steps
Possible Solution(s)
Notes
This is what my code is
use crates_io::*; fn main() { let mut crates = Registry::new(String::from("https://crates.io"), None); let mut query = crates.search("clap",10).unwrap(); }Also, this is the panic message:
thread 'main' panicked at 'called
Result::unwrap()on anErrvalue: failed to get a 200 OK response, got 403headers:
HTTP/2 403
body:
We require that all requests include a
User-Agentheader. To allow us to determine the impact your bot has on our service, we ask that your user agent actually identify your bot, and not just report the HTTP client library you're using. Including contact information will also reduce the chance that we will need to take action against your bot.Bad:
User-Agent: reqwest/0.9.1
Better:
User-Agent: my_crawler
Best:
User-Agent: my_crawler (my_crawler.com/info)
User-Agent: my_crawler (help@my_crawler.com)
If you believe you've received this message in error, please email help@crates.io and include the request id b8cb398a-10fb-4152-99f4-5e1a74571b02.
Output of
cargo version:cargo 1.47.0 (f3c7e06 2020-08-28)
macos big sur
x64