Exemple #1
0
def mk_bing_request(search_term, api_key, callback):
    quoted_search = quote("'{}'".format(search_term))
    url = ("https://api.datamarket.azure.com/Bing/SearchWeb/v1/Web"
           "?Query={}&$format=json").format(quoted_search)
    request = Request(url, callback=callback)
    request_authenticate(request, "", api_key)
    return request
Exemple #2
0
 def test_request_authenticate(self):
     r = Request("http://www.example.com")
     request_authenticate(r, 'someuser', 'somepass')
     self.assertEqual(r.headers['Authorization'], b'Basic c29tZXVzZXI6c29tZXBhc3M=')
Exemple #3
0
 def test_request_authenticate(self):
     r = Request("http://www.example.com")
     request_authenticate(r, 'someuser', 'somepass')
     self.assertEqual(r.headers['Authorization'], 'Basic c29tZXVzZXI6c29tZXBhc3M=')
Exemple #4
0
 def process_request(self, request, spider):
     http_user = getattr(spider, "http_user", "")
     http_pass = getattr(spider, "http_pass", "")
     if http_user or http_pass:
         request_authenticate(request, http_user, http_pass)