Skip to content

Instantly share code, notes, and snippets.

@LitvinenkoD89
Created July 28, 2017 15:38
Show Gist options
  • Save LitvinenkoD89/0cf56da15971574b830bbb8408edc2e1 to your computer and use it in GitHub Desktop.
Save LitvinenkoD89/0cf56da15971574b830bbb8408edc2e1 to your computer and use it in GitHub Desktop.
godfather
# GODFATHERS PIZZA {source_name: 'godfathers', batch_number: 7, request_id: 7000000051, request_name: 'GODFATHERS PIZZA'}
scraper_service.scrape do |browser, scraper, init_vars|
easy_seeder = Library.lib('EasySeeder')
easy_extractor = Library.lib('EasyExtractor')
easy_seeder.seed(source_name: init_vars[:source_name]) do
loop_postal_codes "us", radius: 10 do |zip, lat, long|
queue_url "https://www.godfathers.com/localize", {
method: :post
body: {
"postal_code":"89117",
"occasion": {
"id":2,
"name":"Carryout",
"type":"CARRYOUT",
"service_time":'',
"enabled":true,
"tree_id":77
},
"crumb":"cDZyf5TxXwxBuK94nJNrKNNsKWFlH6f9A6cKvXCUa6q"
}.to_json,
headers: {
'Accept' => 'application/json, application/json;q=0.8, text/plain;q=0.5, */*;q=0.2',
'Accept-Language' => 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4',
'Cache-Control' => 'no-cache',
'Content-Type' => 'application/json',
'Cookie' => 'crumb=cDZyf5TxXwxBuK94nJNrKNNsKWFlH6f9A6cKvXCUa6q; _ga=GA1.2.229398169.1501251980; _gid=GA1.2.805604635.1501251980; _gat=1; renderservice=Fe26.2**4e1cbbf3bf07315fdec847701f0168180c2d0484f1d2c82e49f2c8159ef0fe2a*I1WVdHyBmFbfItMMHIcMTA*1i8AsU31m9csSeplaAAxc_4pHZOsnGCsp1OiVIXsLnXWO2gtPzP2HGKGHz5v0u44**da9d7e9624f524db6014882beba6f552475a173cfccc7873f665aa6edc7419f3*ze61QorcfWi6rgL8kjGEN5HvMdh6AA-a_l1VwOh4yX4',
'Pragma' => 'no-cache',
'Referer' => 'https://www.godfathers.com/contact-us?localization=true&redirect=%2Fdiscounts&reset=true',
'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
}
}
end
end
easy_extractor.extract(
source_name: init_vars[:source_name],
scraper: scraper,
batch_number: init_vars[:batch_number],
request_id: init_vars[:request_id],
request_name: init_vars[:request_name],
) do
find_pages page_format: :json do |url, parser_page, json|
if json && json["stores"].present?
data = json["stores"]
data.each do |store|
doc_id = store_doc({
store_id: store["display_id"],
brand: "GODFATHERS PIZZA",
type: "GODFATHERS PIZZA",
property_id: store["display_id"],
name: store["name"],
address_1: store["address"]["address1"],
address_2: store["address"]["address2"],
city: store["address"]["city"],
state: store["address"]["state"],
zipcode: store["address"]["postal_code"],
country: '',
lat: store["address"]["latitude"],
long: store["address"]["longitude"],
# location_url: store["DealerUrl"],
flags: {
'CARRYOUT' => true
'DELIVERY'=> store["custom_attributes"]["delivery"]
'DINE IN' => store["custom_attributes"]["dineIn"]
'PARTY ROOM' => store["custom_attributes"]["partyRoom"]
'BUFFET' => store["custom_attributes"]["buffet"]
}
# map_link: nil
# address_container_html:
})
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment