473,802 Members | 2,318 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

http fopen problem

I'm trying to write a script which downloads information from a number
of websites analyses it and shows some results.
The problem I'm having is that some sites seem to work perfectly while
others don't. I know it's to do with the complexity of the site, but
I've no idea how to fix it in my code.
At the moment I am just using file_get_conten ts() to get all of the
relevant pages, but when I use this on http://www.dontstayin.com it
just doesn't work!
when I go there with my browser and view the source it's all lovely
html, but when I try to grab it file_get_conten ts() returns
bool(false)
what am I doing wrong, and how can I better emulate an actual
web-browser?

Oct 12 '06 #1
1 1779

<Cl*******@hotm ail.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
I'm trying to write a script which downloads information from a number
of websites analyses it and shows some results.
The problem I'm having is that some sites seem to work perfectly while
others don't. I know it's to do with the complexity of the site, but
I've no idea how to fix it in my code.
At the moment I am just using file_get_conten ts() to get all of the
relevant pages, but when I use this on http://www.dontstayin.com it
just doesn't work!
when I go there with my browser and view the source it's all lovely
html, but when I try to grab it file_get_conten ts() returns
bool(false)
what am I doing wrong, and how can I better emulate an actual
web-browser?
curl returns this as it's source:

HTTP/1.1 302 Found
Connection: close
Date: Thu, 12 Oct 2006 14:04:54 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Location: /pages/home
Cache-Control: private
Content-Type: text/html

<html><head><ti tle>Object moved</title></head><body>
<h2>Object moved to <a href="/pages/home">here</a>.</h2>
</body></html>
Here's how to get that to a text file using curl
http://us2.php.net/manual/en/ref.curl.php

<?php
$ch = curl_init("http ://www.dontstayin. com/");
$fp = fopen("dontstay in_homepage.txt ", "w");

curl_setopt($ch , CURLOPT_FILE, $fp);
curl_setopt($ch , CURLOPT_HEADER, 1);

curl_exec($ch);
curl_close($ch) ;
fclose($fp);
?>
:^D


Oct 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5553
by: Tank | last post by:
ld.so.1: internal: malloc failed I'm getting the above on a simple fopen() in a production program. I know that fopen calls malloc, but what would cause this and how do I fix it? Have I hit some kind of # files open limit or something? I'm running in Solaris 2.6. Barry Perot Systems
2
2296
by: Thomas Baruchel | last post by:
Hi, wondering about: func1: setjmp() ; func2(); func2: {FILE *f; f = fopen(); func3(); fclose(f)} func3 : if() longjmp; else return; Note that FILE *fis a local variable in func2.
7
3038
by: git_cs | last post by:
Hey, guys and gals Somedays ago, I had asked for the DES algorithm in C language. Although I have written the algorthim in C myself, I am facing a peculiar problem, which I hope some of u guys and gals solve. I use Turbo C++ version 3.0 and WINXP as the operating system. Pls observe the following program. 1 #include<stdio.h> 2 #include<conio.h>
3
2596
by: Patrice | last post by:
Hi, I would to call fopen function several time in my application. This application permits to read files which path is registered in a configuration file. For exemple: File 1 = toto.txt File 2 = tot2.txt ....File N = TotoN.txt Then, I read each file (one by one), get adress of the beginning of data and size of data.
19
6813
by: lihua | last post by:
Hi, Group! I got one question here: We all know that fclose() must be called after file operations to avoid unexpected errors.But there are really cases when you forget to do that!Just like what happens in memory operations, everyone knows the importance of freeing the allocated memory, but there do have memory leaks from time to
10
4781
by: pjlsr | last post by:
It's close to twenty years since I used the C language and at that time I was doing only floating point computational work, nothing with strings or reading files. I tried to use fopen in the following manner. a file name is entered by keyboard , fgets is used to read the name. printf is used to confirm that the name was correctly read. Then infile=fopen("filename","r") is used to open the file which very definitly exists. It returns '0' as...
2
3631
by: Mike | last post by:
Hello, Im doing this in php5, apache Im not sure where the problem lies but I have a file <?php Class CreateXML{ public function xmlDeclaration(){ return $varxmlDec = "<?xml version='1.0'> "; } public function rssDeclaration(){ return $varrssDec = "<rss version='2.0'>";
5
3279
by: xieliwei | last post by:
I have a freshly installed openSuSe 10.2 with PHP4 from http://download.opensuse.org/repositories/home:/michal-m:/php4/openSUSE_10.2/ (openSuSe abandoned PHP4 since version 10, but I have customers who need php4 support) The version strings are as follows: # uname -a Linux server2 2.6.18.2-34-default #1 SMP Mon Nov 27 11:46:27 UTC 2006 i686 athlon i386 GNU/Linux
3
3453
by: IamtheEvster | last post by:
Hi there, I'm using fopen for the first time and I know I'm running into a permissions problem, but I can't seem to resolve it and any help would be greatly appreciated. I'm running PHP5 and Apache on RedHat Enterprise Linux 4. I've verified (by looking in httpd.conf) that Apache is running as user "apache" and group "apache". So, that's the user/group that PHP
4
2841
by: Michel Rouzic | last post by:
I made a program that accepts as parameters an input file name that we'll call file1, and an output file name that we'll call file2, and opens on its own a configuration file called file3. My program works correctly when calling it like this : ./program file1 file2, and also with full paths, like this : ./program c:\dir\file1 c:\dir\file2 However, a most puzzling phenomenon occurs when I use the full path only for the first file, like...
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10532
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10302
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10281
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9111
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3789
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.