Jump to content

chetankchandak

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by chetankchandak

  1. I want to extract current data from a particular website(http://www.ncdex.com/MarketData/LiveFuturesQuotes.aspx) and then show it on my website. I want to extract only if the Data is "Chana" or else move to next line or stop. Because the website keeps on updating and the field(Chana) always changes its rows. Please help me. <html> <body> <?php $html = file_get_contents('http://www.ncdex.com/MarketData/LiveFuturesQuotes.aspx'); //get the html returned from the following url libxml_use_internal_errors( true); $doc = new DOMDocument; $doc->loadHTML( $html); $xpath = new DOMXpath( $doc); $node4a = $xpath->query( '//*[@id="ctl00_ContentPlaceHolder3_dgLiveFuturesQuotes"]/tbody/tr[11]/td[1]/a')->item( 0); $node4b = $xpath->query( '//*[@id="ctl00_ContentPlaceHolder3_dgLiveFuturesQuotes"]/tbody/tr[11]/td[7]')->item( 0); $node4c = $xpath->query( '//*[@id="ctl00_ContentPlaceHolder3_dgLiveFuturesQuotes"]/tbody/tr[11]/td[8]')->item( 0); $src4 = $xpath->query( '//*[@id="ctl00_ContentPlaceHolder3_dgLiveFuturesQuotes"]/tbody/tr[11]/td[7]/img/@src')->item( 0); $node4d = $xpath->query( '//*[@id="ctl00_ContentPlaceHolder3_dgLiveFuturesQuotes"]/tbody/tr[11]/td[2]')->item( 0); echo $node4a->textContent; // This will print **Chana** echo $node4b->textContent; echo $node4c->textContent; echo $img1; echo $src4->nodeValue; echo $img2; echo "|"; echo $node4d->textContent; echo "<br>"; ?> </html>
  2. thanks but solved it from other way <?php // get host name from URL preg_match('@^(?:http://) ?([^%]+)@i', "http://www.shopclues.com/1862-hey-dude-footwear.html%3Fref%3D20", $matches); $host = $matches[1]; echo "<br>"; $site_url=str_replace("www.","",$host); echo $site_url; ?>
  3. From http://www.shopclues.com/1862-hey-dude-footwear.html%3Fref%3D20 I want the output to display shopclues.com/1862-hey-dude-footwear.html data after . and before % I think i am missing something in the preg_match Plz help <?php // get host name from URL preg_match('@^(?:http://)?([^%]+)@i', "http://www.shopclues.com/1862-hey-dude-footwear.html%3Fref%3D20", $matches); $host = $matches[1]; // get last two segments of host name preg_match('/[^.]+\.[^.]+$/', $host, $matches); echo "domain name is: {$matches[0]}\n"; ?>
  4. I have used a variable in the WHERE clause i.e. "$hostt", which is not giving the output results. When I directly put the values, it gives me the desired results. Plz help <?php $con=mysqli_connect("localhost","root","root","dbname"); // Check connection if (mysqli_connect_errno($con)) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } echo $params = $_SERVER['QUERY_STRING']; // get host name from URL preg_match('@^(?:http://)?([^/]+)@i', "$params", $matches); $host = $matches[1]; // get last two segments of host name preg_match('/[^.]+\.[^.]+$/', $host, $matches); echo "domain name is: {$matches[0]}\n"; $hostt = "{$matches[0]}\n" ; // everything works fine till here. $result = mysqli_query($con,"SELECT * FROM main WHERE store = '$hostt'"); while($row = mysqli_fetch_array($result)) { echo $row['prefix'] . "http://www." . $row['store'] . $row['suffix']; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.