# How to move on to next url if current one is a dud

**URL:** <https://www.ruby-forum.com/t/how-to-move-on-to-next-url-if-current-one-is-a-dud/146159>\
**Category:** Ruby\
**Created:** [August 18, 2008, 4:39pm UTC](https://www.ruby-forum.com/t/how-to-move-on-to-next-url-if-current-one-is-a-dud/146159 "2008-08-18T16:39:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scudco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@scudco](https://www.ruby-forum.com/u/scudco)\
**Post date:** [August 18, 2008, 4:39pm UTC](https://www.ruby-forum.com/t/how-to-move-on-to-next-url-if-current-one-is-a-dud/146159/1 "2008-08-18T16:39:21Z")

</div>

hmm wasnt too sure how to make the subject both concise and  
understandable at the same time so my apologies if i was vague.

I searched under “ignore missing” but didnt come up wiht anything.  
Perhaps someone can help me.

Im using open-uri to fetch the html from various ebay webpages.  
Basically the results for certain categories. I have all the relevant  
urls tucked into an array of hashes eg. Computers =\>  
www.ebay.blah.blah.blah

I then cycle through the array feeding open uri the urls and doing my  
biz on the html one by one.

However sometimes there are no products for a certain category for that  
given day (im focussing on products located in japan so the number of  
results is drastically reduced) so when open uri complains like this

ebay.rb:71:in `read’: No such file or directory -  
[http://research.ebay.co.uk/ws/](http://research.ebay.co.uk/ws/)  
search/GetSaleAnalysis?sojs=0&salic=104&sacqyop=9&sacqy=1000&sacat=13851&ftrv=17  
&fis=2&fts=-1&fn=4&frts=0&sc=AvgSoldPrice&showdiag=0&soexpand=1&soraw=0  
(Errno::  
ENOENT)

Im fine with it complaining but it stops the programme. How do i make it  
simply skip/ignore such urls and move on to the next one in the hash?

any help greatly appreciated.

---

<div class="post-metadata">

**Author:** ![scudco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@scudco](https://www.ruby-forum.com/u/scudco)\
**Post date:** [August 18, 2008, 4:44pm UTC](https://www.ruby-forum.com/t/how-to-move-on-to-next-url-if-current-one-is-a-dud/146159/2 "2008-08-18T16:44:49Z")

</div>

On Monday 18 August 2008, Adam A. wrote:

> rv=17  
> &fis=2&fts=-1&fn=4&frts=0&sc=AvgSoldPrice&showdiag=0&soexpand=1&soraw=0  
> (Errno::  
> ENOENT)
> 
> Im fine with it complaining but it stops the programme. How do i make it  
> simply skip/ignore such urls and move on to the next one in the hash?
> 
> any help greatly appreciated.

Wrapping the call to open in a begin/rescue pair should do what you  
want:

begin open( url )  
rescue SystemCallError  
end

I hope this helps

Stefano

---

<div class="post-metadata">

**Author:** ![scudco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@scudco](https://www.ruby-forum.com/u/scudco)\
**Post date:** [August 18, 2008, 5:49pm UTC](https://www.ruby-forum.com/t/how-to-move-on-to-next-url-if-current-one-is-a-dud/146159/3 "2008-08-18T17:49:23Z")

</div>

On Aug 18, 2008, at 10:40 AM, Stefano C. wrote:

> > www.ebay.blah.blah.blah  
> > [http://research.ebay.co.uk/ws/](http://research.ebay.co.uk/ws/)  
> > simply skip/ignore such urls and move on to the next one in the hash?  
> > I hope this helps
> 
> Stefano

You might want to rescue just Errno::ENOENT.

I often do:

```
 rescue Timeout::Error, OpenURI::HTTPError, Errno::ENOENT

```

for this kind of thing.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid
