Getting all links of a webpage using Ruby

前端 未结 5 1397
盖世英雄少女心
盖世英雄少女心 2021-02-08 06:36

I\'m trying to retrieve every external link of a webpage using Ruby. I\'m using String.scan with this regex:

/href=\"https?:[^\"]*|href=\'https?:[^\         


        
5条回答
  •  名媛妹妹
    2021-02-08 07:35

    why you dont use groups in your pattern? e.g.

    /http[s]?:\/\/(.+)/i
    

    so the first group will already be the link you searched for.

提交回复
热议问题