User Tools

Site Tools


using_requests_an_elegant_and_simple_http_library_for_python_built_for_human_beings
import requests
import pandas as pd
import numpy as np
from StringIO import StringIO
 
web_api_name = requests.session()
 
def link(x): 
    return 'https://web_api_name.php?scenario='+ api_report +'&page=' + x
 
pages = [str(x) for x in range(7) if x != 0]
 
links = map(link, pages)
 
result = []
 
for link in links:
    res = web_api_name.get(link, auth=('user',
                                       'pass'), 
                        verify=False)
    result.append(res)
 
page_dfs = [pd.DataFrame.from_csv(StringIO(r.text)) for r in result if r.status_code == 200]
df = pd.concat(page_dfs).reset_index()
using_requests_an_elegant_and_simple_http_library_for_python_built_for_human_beings.txt · Last modified: 2016/10/07 16:09 by vincenzo