method to pull security advisory urls from index_url now works
This commit is contained in:
parent
6e588a3578
commit
aae01c1e57
1 changed files with 8 additions and 3 deletions
|
@ -13,12 +13,17 @@ class MozillaSecurityAdvisoryScraper
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_index
|
def get_index
|
||||||
|
headers = {
|
||||||
|
:accept => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
|
||||||
|
:user_agent => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0'
|
||||||
|
}
|
||||||
response = RestClient::Request.execute(
|
response = RestClient::Request.execute(
|
||||||
:method => :get,
|
:method => :get,
|
||||||
:url => index_url
|
:url => index_url,
|
||||||
|
:headers => headers
|
||||||
)
|
)
|
||||||
if response.code == 200
|
if response.code == 200
|
||||||
r.body
|
response.body
|
||||||
else
|
else
|
||||||
puts "HTTP Status code: #{r.code}"
|
puts "HTTP Status code: #{r.code}"
|
||||||
end
|
end
|
||||||
|
@ -29,7 +34,7 @@ class MozillaSecurityAdvisoryScraper
|
||||||
end
|
end
|
||||||
|
|
||||||
def advisory_urls(html_doc)
|
def advisory_urls(html_doc)
|
||||||
html_doc.xpath('//li[@class="level-item"]/a').map {|link| link['href']}
|
html_doc.xpath('//li[@class="level-item"]/a').map {|link| relative_url = link['href']; "https://www.mozilla.org#{relative_url}"}
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_advisory_urls
|
def get_advisory_urls
|
||||||
|
|
Loading…
Add table
Reference in a new issue