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

  • SEARCH
  • Home
  • 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 8889185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:12:02+00:00 2026-06-14T22:12:02+00:00

I’ll give you the gist. I’m trying to scrape certain URL’s using a third

  • 0

I’ll give you the gist.

I’m trying to scrape certain URL’s using a third party HTML tag stripper because I don’t think the default strip_tags() does the job well. (I don’t think you need to check that scraper)

Now sometimes, the HTML source code of some sites contains some weird code that is causing my HTML tag stripper to fail.

One such example is this site that contains the following piece of code :

<li><a href="<//?=$cnf['website']?>girls/models-photo-gallery/?sType=6#top_menu">Photo Galleries</a></li>

that causes the above mentioned tag stripper to throw this error :

Parse error: syntax error, unexpected
T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or
T_NUM_STRING in /var/www/GET
Tweets/htdocs/tmhOAuth-master/examples/class.html2text.inc(429) :
regexp code
on line 1

Fatal error:
preg_replace() [<a
href=’function.preg-replace’>function.preg-replace</a>]:
Failed evaluating code:
$this-&gt;_build_link_list(&quot;&lt;//?=$cnf[\’website\’]?&gt;girls/models-photo-gallery/?sType=6#top_menu&quot;,
&quot;Photo Galleries&quot;) in /var/www/GET
Tweets/htdocs/tmhOAuth-master/examples/class.html2text.inc
on line
429

Now what happens is, there is an array of many URLs and some throw the abovementioned error. I do some processing on each URL.

If some URL in the array throws an error like this, I want the execution to proceed ahead with processing of next URL without it disturbing anything. My code is something like this:

foreach ($results as $result)
{
    $url=$result->Url;

    $worddict2=myfunc($url,$worddict2,$history,$n_gram);        
}

Here myfunc does the processing and uses the 3rd party HTML stripper I mentioned before.
I tried modifying the code to this:

foreach ($results as $result)
    {
        $url=$result->Url;
        $worddicttemp=array();
        try
        {
            $worddicttemp=myfunc($url,$worddict2,$history,$n_gram); //returns the string represenation of what matters, hopefully
            //The below line will be executed only when the above function doesn't throw a fatal error
            $worddict2=$worddicttemp;
        }
        catch(Exception $e)
        {
            continue;
        }
    }

But I’m still getting the same error.
What is wrong? Why is the code inside myfunc() now transferring control to the catch blocks as soon as it encounters that fatal error?

  • 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-14T22:12:04+00:00Added an answer on June 14, 2026 at 10:12 pm

    You can’t catch Parse Errors (or any Fatal Errors for that matter, but Parse Errors are even worse since they’ll be generated as soon as the code is loaded). The best way I know of to isolate them is to run completely independent PHP processes for whatever you want to recover from and expect to generate Fatal Errors.

    See also How do I catch a PHP Fatal Error

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I am trying to understand how to use SyndicationItem to display feed which is

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.