php


Retrieve table data from another webpage using PHP


I want to retrieve some data that in a table format form that webpage i need in my webpage.
I follow many link and solution from stackoverflow but i can't get any data.
Below are the URL that data i want to retrieve:
http://www.ip2location.com/demo/1.22.99.222
In the above URL one information table that data i want get.
Please anyone provide the code for retrieve data.
Thank you in advance.
Here are the code. I can't get any error from this code. Also can't get output of regex filter code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome To MY Page</title>
</head>
<body>
<div class="signform">
<?php
// Function to get the client ip address
echo "<br/>".$_SERVER['REMOTE_ADDR'];
echo "<br/>".$_SERVER['SERVER_NAME'];
echo "<br/>".$_SERVER['SERVER_SOFTWARE'];
echo "<br/>".$_SERVER['SERVER_PROTOCOL'];
echo "<br/>".$_SERVER['ALL_HTTP'];
echo "<br/>".$_SERVER['HTTP_USER_AGENT']."<br/>";
// These lines are mandatory.
require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
// Any mobile device (phones or tablets).
if ( $detect->isMobile() ) {
echo "Device Type : Mobile";
}
// Any tablet device.
else if( $detect->isTablet() ){
echo "Device Type : Tablet";
}
else {
echo "Device Type : PC";
}
$ip = $_SERVER['REMOTE_ADDR'];
echo $ip;
$content = file_get_contents("http://www.ip2location.com/demo/$ip");
preg_match_all('/<body>(.*?)<\/body>/s',$content,$output,PREG_SET_ORDER);
echo $output;
echo "<br/> ISP : ".$isp."<br/> City : ".$city."<br/> State : ".$state."<br/> Country : ".$country."<br/> zipcode : ".$zipcode;
?>
</div>
</body>
</html>
Here are the Screenshot of Output:
1.22.98.173
appstechsolution.in
Apache Phusion_Passenger/4.0.10 mod_bwlimited/1.4 mod_fcgid/2.3.9
HTTP/1.1
Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36
Device Type : PC1.22.98.173Array
ISP :
City :
State :
Country :
zipcode :
Use simpleHTMLDom this will load destination web page and scrap needed table.
include_once('classes/simple_html_dom.php');
$html = file_get_html('http://www.ip2location.com/demo/1.22.99.222');
echo $html->find("#main-content .table", 0);

Related Links

redirecting a long URL to https
How to embed this php code in html?
Uncaught Error: Call to undefined function curl_init()
Multi level login by address
SELECT * FROM table WHERE `id` in … and where sum() less
Laravel: Undefined method fake on Laravel storage facades for file upload testing
Very Complex SQL Data Result Merge via PHP (Multi Dimentional Arrays)
codeigniter Insert_batch not working
How do I fix this invalid JSON that wasn't escaped? (in PHP)
PHP: how to adding date with number of month from database? [duplicate]
Illegal string offset 'class' in ( php 7.1.1 ) [duplicate]
How to Create a shortcut automatically on mobile to a website
Automatization of a conditional function through the use of an array to test postdata variables
get form values from one php “echo” to the other
Prepare data for inserting ST_GeomFromText in database (Codeigniter + MySql)
Having issues with this Mysql query

Categories

HOME
opengl
openshift
protocol-buffers
opencart
schema.org
selenium-builder
enums
braintree
openlayers-3
portable-class-library
mathematical-optimization
lvm
greasemonkey
ipv6
linker
azure-mobile-services
wagtail
angular2-template
kurento
migrate
scrape
match
alljoyn
game-maker
feature-extraction
jquery-file-upload
stimulsoft
bnf
codefluent
cpu-usage
wsf
libgit2
gitkraken
activeadmin
bosun
liferay-6.2
altium-designer
websphere-portal
exchange-server-2010
router
ipa
boolean-logic
premake
private-key
ms-media-foundation
assertions
runtimeexception
macports
aurelia-cli
text-decorations
widestring
utf
google-prediction
morphline
nomad
.net-micro-framework
cloudwatch
sony-future-lab-n
md5-file
mongodb-aggregation
degrees
google-shopping-api
cocoa-bindings
yui3
xmlbeans
logical
dcount
system.web.optimization
svnserve
maven-release-plugin
frame-grab
mercurial-extension
android-expansion-files
ngcordova
roxygen2
embeddedwebserver
baseadapter
rubber
windows-rt
oracle-adf-mobile
webmethod
sql-function
flipboard
usb-flash-drive
spring-social-linkedin
smips
codahale-metrics
libxml-js
postgres-xc
sunstudio
chartfx
jquery-lazyload
semantic-merge
multiple-dispatch
idispatch
onconfigurationchanged
playorm
telerik-ajax
trialware
nsrangeexception
jquery-1.4
digiflow
ninject-interception
resharper-5.1
3-tier
uninstaller
projectpier
fxruby
subtext
chronic
rendering-engine

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App