function Start() { global $conn; //get base URL screen by GET $url = 'http://www.fangraphs.com/projections.aspx?pos=all&stats=bat&type=steamer'; $browser = new ASPBrowser(); $html = $browser->doGetRequest($url); // get form echo $html; $postArray = array('__EVENTTARGET' => 'ProjectionBoard1%24dg1%24ctl00%24ctl02%24ctl00%24ctl07', '__SCROLLPOSITIONY' => '520'); // $browser->exclude = array('ctl00$ImgCon'); //setup session on server $html = $browser->doPostRequest($url, $postArray); echo $html; //setting state finish }
function removeSpaces($s) { return trim(preg_replace('!\\s+!', ' ', $s)); } /**Print table of html results * @param simple_html_dom $dom */ function printTableData(simple_html_dom $dom) { foreach ($dom->find('tr.gridViewRow, tr.gridViewAlternateRow') as $tr) { $td = $tr->find('td'); echo removeSpaces($td[0]->innertext . ';' . $td[1]->innertext . ';' . $td[2]->innertext . ';'); echo $td[3]->find('a', 0)->href . ';'; echo $td[4]->find('img', 0)->alt . "\n"; } } $url = 'https://ucpi.sco.ca.gov/ucp/Default.aspx'; $browser = new ASPBrowser(); $browser->exclude = array('ctl00$ContentPlaceHolder1$btnClear'); $browser->doGetRequest($url); // get form $resultPage = $browser->doPostRequest($url, array('ctl00$ContentPlaceHolder1$txtLastName' => 'smith')); // hit seach, get 1st page of results $browser->exclude = array('ctl00$ContentPlaceHolder1$btnClearInd', 'ctl00$ContentPlaceHolder1$ddlPageSize', 'ctl00$ContentPlaceHolder1$btnSearchInd'); // set exclude for search results for ($i = 2; $i < 5; $i++) { printTableData($resultPage); $resultPage = $browser->doPostBack($browser->lastUrl, 'ctl00$ContentPlaceHolder1$gvResults', 'Page$' . $i); } printTableData($resultPage); $resultPage->clear();
function Start() { global $conn; $url = 'http://indiawater.gov.in/IMISReports/Reports/EntryStatus/Rep_FinancialPhysicalProgressReport_S.aspx?Rep=0&Rtype=PH'; $browser = new ASPBrowser(); $html = $browser->doGetRequest($url); // get form $data = getExtractedDataC14States($html, 25); echo json_encode($data); //doDataInsertScrapec14States($data); // stored state list. now processing state BIHAR //$sql = "SELECT * FROM `scrape_c14_states` WHERE `c14_2`='BIHAR'"; //$state_result = mysqli_query($conn, $sql) or trigger_error(mysqli_error($conn)." ".$sql); //$state_row = mysqli_fetch_assoc($state_result); // $seed = str_replace('_','$',$state_row['target']); $seed = 'ctl00$upPnl|ctl00$ContentPlaceHolder$rpt$ctl05$lkbstate'; $postArray = array('__EVENTTARGET' => $seed, '__EVENTARGUMENT' => '', '__LASTFOCUS' => '', '__ASYNCPOST' => 'true', 'ctl00$ScriptManager1' => 'ctl00$upPnl|' . $seed, 'ctl00$ContentPlaceHolder$ddfinyear' => '2015-2016', 'ctl00$ContentPlaceHolder$ddState' => '005', 'ctl00$ContentPlaceHolder$RadioButtonListType' => 'All', 'ctl00$ddLanguage' => ''); //echo json_encode($postArray); die(); $browser->exclude = array('ctl00$ContentPlaceHolder$btnGO'); //setup session on server $browser->exclude = array('Map'); $browser->exclude = array('aspnetForm'); $browser->exclude = array('ctl00$ImgCon'); $browser->exclude = array('cctl00$ImgBri'); $browser->exclude = array('ctl00$convertWord'); $browser->exclude = array('ctl00$convertEXCEL'); $browser->exclude = array('ctl00$ImgCon'); $browser->doPostRequest($url, $postArray); $url = "http://indiawater.gov.in/IMISReports/Reports/EntryStatus/Rep_FinancialPhysicalProgressReport_D.aspx?Rep=0&Rtype=PH"; $html = $browser->doGetRequest($url); // get form $data = getExtractedDataC14DistrictsAll($html, 5); echo json_encode($data); doDataInsertScrapeB1DistrictsAll($data, $state_row['id']); }