Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8261997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:36:44+00:00 2026-06-08T03:36:44+00:00

My problem is that the following script works with some IRI’s and with others

  • 0

My problem is that the following script works with some IRI’s and with others not, and my question is why does it behave this way and how to solve it.
I think there is problem with the charset but it’s only a guess because in Wikipedia it works.

<?php
include('C:\xampp\htdocs\php\simple_html_dom.php');
$html = file_get_html('http://de.wikisource.org/wiki/Am_B%C3%A4chle');
//Titel
foreach($html->find('span#ws-title') as $f)
echo $f->plaintext;

//1   http://de.wikisource.org/wiki/7._August_1929           OK
//2   http://de.wikisource.org/wiki/%E2%80%99s_ist_Krieg!    -
//3   http://de.wikisource.org/wiki/Am_B%C3%A4chle           -
//4   http://de.wikipedia.org/wiki/Guillaume-Aff%C3%A4re     OK
//5   http://de.wikisource.org/wiki/Solidit%C3%A4t           -
?>

The 5 IRI’s are the examples. The last 3 IRI’s contain %C3%A4, it’s an “ä” but only the one from wikipedia works. The 2. IRI contains %E2%80%99 it’s an ” ’ ” – doesn’t work.

But the first IRI from wikisource works. The same for every IRI from wikisource which does not contain any ä, ö, …

When it does not work I get the following warning:

Warning: file_get_contents(http://de.wikisource.org/wiki/Solidit%C3%A4t): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in C:\xampp\htdocs\php\simple_html_dom.php on line 70

Fatal error: Call to a member function find() on a non-object in C:\xampp\htdocs\php\frage.php on line 5

The function which contains line 70 in simple_html_dom.php looks like that:

//65    function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT)
//66    {
//67    // We DO force the tags to be terminated.
//68    $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $defaultBRText);
//69    // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
//70    $contents = file_get_contents($url, $use_include_path, $context, $offset);
//71    // Paperg - use our own mechanism for getting the contents as we want to control the timeout.
//72    //    $contents = retrieve_url_contents($url);
//73    if (empty($contents))
//74    {
//75        return false;
//76    }
//77    // The second parameter can force the selectors to all be lowercase.
//78    $dom->load($contents, $lowercase, $stripRN);
//79    return $dom;
//80    }

Is there any way to get the script working for every IRI in Wikipedia or Wikisource? (I know that there is not always a span#ws-title, that’s not my problem.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:36:46+00:00Added an answer on June 8, 2026 at 3:36 am

    Awesome question! 🙂

    They seem to filter by user agent, try something like

    <?php
    ini_set("user_agent", "Descriptive user agent string");
    file_get_contents("http://de.wikisource.org/wiki/".urlencode("Am_Bächle"));
    ?>
    

    you can probably skip the urlencode part since I just used it to test whether the encode was right.

    Please note that wikisource obviously dislikes automated parsing of their content on the web pages. Nonetheless there might be an API available for wikibots and the like, ask them or search the community pages. The API will be much easier to handle anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm going mad with the following problem which does not happen on any other
I'm doing the following, which basically works. The script tries to insert some lines
I have the following problem. I have a script that gets the Airdate of
I'm making a Billing system with some friends, it works this way: The customers
The problem: I have a function that partially works and for some reason it
I have the following problem: I have some test scripts that previously were run
I have the following problem that I want to solve in awk. I have
I have the following problem that the standard library doesn't solve well, and I'm
I have the following problem that other people must have encountered. I am working
I have the the following problem that starts to drive me nuts. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.