473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

how to fetch contents of external webpage and save it in txt file.

rishidadhich
hello,
I am new to PHP,

I am stuccked in a problem that how to fetch text contents from a external website and then save them to a text file.

say there is any webpage www.xyz.com/index.html now i have to fetch all the text contents from the page index.html and have to save in a file.

I have no problem with XML or PAD formats but when it comes to HTML page I am Clueless..

can any body guide me through this.....

Thanx in advance..
Feb 9 '07 #1
2 2507
xwero
99
try
[PHP]
$lineArray = file('http://www.test.com/');
foreach($lineArray as $line){
if(strlen($line) > 0){
echo strip_tags($line).'<br>';
}
}
[/PHP]

this way you have a line for every linebreak that exists in the file you try to retrieve.

Some site prevent scraping then you can try to use a socket connection
Feb 9 '07 #2
try
[PHP]
$lineArray = file('http://www.test.com/');
foreach($lineArray as $line){
if(strlen($line) > 0){
echo strip_tags($line).'<br>';
}
}
[/PHP]

this way you have a line for every linebreak that exists in the file you try to retrieve.

Some site prevent scraping then you can try to use a socket connection

hi xwero,
thanx for the suggestion, its working.

thanx again
Feb 10 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John Chen | last post by:
I need to use iframe to create a floating frame. But the contents in the iframe is not a external html file. Rather, it will be dynamically created by jsp. How can I set the src attribute to a URL...
3
by: MrXs | last post by:
hi how do i save the contents of a axWebBrowser1 to a htm file ? i have a webpage loaded and would like to save it to my harddrive. also how do i open the file from my harddrive to open in...
0
by: wingman | last post by:
Hello All I'm completely new to ASP.Net. I need to write a page to fetch an external call which actually call a Java program to download a file, the content of this downloaded is...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
4
by: orware | last post by:
Hi! This is my first post...and when I begin working on this project, it will also be my first PHP project! I do have some programming experience from my first year at college, but that was in Scheme...
17
by: broughcut | last post by:
Is it possible to fetch a specific div from a source html document using XMLHttpRequest, rather than fetching the entire file? I was going to use Ajax on mouseover but keep the normal link...
1
by: PulkitZery | last post by:
Hi, I am creating a webpage in vb.net and this webpage has frames. Now the problem I have is, in one of the frames I want to show a MS Word or PDF file. If I set the source of this frame to...
1
by: danasegarane | last post by:
Hi all, I am creating a asp file which shows the xml file using this code 'Function to Create XML contents and return Private Function CreateXMLFileContents() 'Create an XML document...
1
by: raj85 | last post by:
i want to compare 2 same files which is located at different location. i olready created 2 file browser button. now i juz need c# code to do comparing text of the both files. it muct check both...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.