public
Created

Scraping Online Drug Stores

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
{
"cvs" => {
"Image" => "//div[@class='productSection1']//img[1]/@src",
"Title" => "//h4[@class='productBrand']//span[1]",
"Size" => "//span[@class='prodWeight']/preceding-sibling::text()[1]",
"Price" => "//*[@class='productPrice']",
"Link" => "//div[@class='productSection1']//img[1]/ancestor::a/@href"
},
 
"walgreens" => {
"Image" => "//div[@class='product-container']/div[contains(@class, 'image_container')]//img[1]/@src",
"Title" => "//div[@class='product-container']//div[contains(@class, 'product-name')]",
"Details" => "//div[@class='product-container']//div[@class='prod-info-box']",
"Price" => "//div[@class='product-container']//div[@class='pricing']/div[@class='prod-pricing']",
"Link" => "//div[@class='product-container']/div[contains(@class, 'image_container')]//img[1]/ancestor::a/@href"
},
 
"drugstore.com" => {
"Image" => "//div[@class='prodImg']//img/@src",
"Title" => "//div[@class='info']/span[@class='description']//span[@class='name']",
"Details" => "//div[@class='info']/span[@class='description']",
"Price" => "//div[@class='pricing']",
"Link" => "//div[@class='prodImg']//img/ancestor::a/@href"
},
 
"MyOTCStore" => {
"Title" => "//span[@class='CategoryProductNameLink']",
"Price" => "//span[@class='CategoryProductPrice']",
"Image" => "//div[@class='CategoryProductThumbnailArea']//img/@src",
"Link" => "//table[@id='dlProducts']//span[@class='CategoryProductNameLink']/a/@href"
},
 
"FamilyMeds" => {
"Title" => "//table[@class='productSearchListing']//td[position()=2 and following-sibling::td]/a[1]",
"Price" => "//table[@class='productSearchListing']//td[3]//p",
"Image" => "//table[@class='productSearchListing']//td[1]/a/img/@src",
"Details" => "//table[@class='productSearchListing']//td[position()=2 and following-sibling::td]/a[1]/following-sibling::p[1]",
"Link" => "//table[@class='productSearchListing']//td[position()=2 and following-sibling::td]/a[1]/@href"
},
 
"CanadaDrugs" => {
"Title" => "//div[@id='results']/div[contains(@class, 'row') and (.//@data-price)]//div[@class='link']/a",
"Price" => "//div[@id='results']/div[contains(@class, 'row') and (.//@data-price)]/div[@class='detailsLink']//select/option[1]/@data-price",
"Image" => "//div[@id='results']/div[contains(@class, 'row') and (.//@data-price)]//div[@class='imageGroup']//img/@src",
"Details" => "//div[@id='results']/div[contains(@class, 'row') and (.//@data-price)]//div[@class='iconGroup']/following-sibling::*[@name!='b' and position()=1]",
"Link" => "//div[@id='results']/div[contains(@class, 'row') and (.//@data-price)]//div[@class='link']/a/@href"
},
 
"thebestonlinepharmacy" => {
"Title" => "//div[@class='product-group']//h2",
"Price" => "//tr[@class='productdetail']//td[2]",
"Image" => "//div[@class='product-group']//img/@src",
"Details" => "//table[@class='mpllc-body']//p",
"Link" => "//tr[@class='productdetail']//td[4]//a/@href"
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.