문제

I am trying to use Nokogiri to scrape a little bit of information from Amazon.

For some reason it takes about 50 seconds for this process to complete. Am I doing something wrong that is making the code inefficient, or is that just how long it would take?

url = "http://www.amazon.com/dp/" + item["ASIN"]
page = Nokogiri::HTML(open(url))
@numreviews = page.css('#averageCustomerReviews > a').text

I have this in a loop that does this to twenty different URLs. Is there anyway to speed this up, or is it just that the pages it has to load to get the information will take that long?

도움이 되었습니까?

해결책

This can be because the response of this URL is too big. You can use the Amazon API which will give you selected information in XML, which will be easy to parse as well.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top