473,594 Members | 2,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Erroneous Text Extraction using HTML::Parser

Hello,
I am using HTML::Parser to extract text from html pages from
http://bbc.co.uk/urdu/

However the encoding of the input text seems to change to some
unknown encoding in the output.

The program is given below. The HTML is in a string to keep the
example simple. The same problem appears with HTML in a file.

############### ############### ############### ############### #####
use HTML::Parser;

# set standard output to utf8
binmode(STDOUT, ":utf8");

# Create parser object
my $p = HTML::Parser->new( api_version => 3, text_h => [\&text,
"text"] );

# parse UTF-8 encoded arabic text
$p->parse( "<html> <body>
پاکستان </body> </html>");

sub text
{
my ($txt) = @_;
print $txt;
}
############### ############### ############### ############### #####

Also, I am unable to pin point the problem by looking at the
parser source code because HTML/Parser.pm doesn't seem to contain any
code that does the real parsing work.

Thank You
Himanshu.
Jul 19 '05 #1
0 2713

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

Similar topics

1
11910
by: Mitchua | last post by:
I am trying to use HTML::Parser to parse an HTML file, remove all HTML tags (including comments, etc.), replace all ENTITIES (e.g. &amp), and put the result into a variable as a string. I figure HTML::Parser itself can somehow preform the filtering, but how do I get it back as a string? I'd appreciate some sample code if anyone has any. Sorry if this is a real n00b question. Thanks a lot, Mitchua
2
1815
by: FrankMCook | last post by:
I'm trying to install SpamAssassin under cygwin and I get an error that I'm missing HTML::parser 3.24. I figure I've got to do something in CPAN but everything I've tried is unrecognized. Anyone know what to do or where to look for instructions?
14
3132
by: WUV999U | last post by:
Hi I am fairly familiar in C but not much. I want to know how I can write a html parser in C that only parses for the image file in the html file and display or print all the images found in the html file. How to go about it?
2
5373
by: Big D | last post by:
Hi all, I'm working on a little app that will go through a text file (right now a "rich text" document), and parse it into a pseudo-html that our flash programmers can use in their presentation. I'm having a lot of trouble, because the rtf format is quite complicated... at first we thought it seemed that there was no "nesting" of formatting, but every once in a while it seems like there is. Also, depending on the complexity of the...
2
2548
by: Craig Kenisston | last post by:
Hi, Could someone recommend any decedent html parser ? All what I need to do is to extract the links from a given page. I've found several tools in codeproject but all seems to be a bit inmature, yet. I'd like to hear opinions and personal experiences with any c# html parser. Thanks in advance.
3
685
by: SEGACO | last post by:
Hi, Can someone tell me if C# includes something to parse HTML? Thanks.
2
2657
by: David Virgil Hobbs | last post by:
Loading text strings containing HTML code into an HTML parser in a Javascript/Jscript I would like to know, how one would go about loading a text string containing HTML code, so as to be able to use javascript or Jscript to work with the HTML code in the text string, in the same way that one works with XML code in a text string using the XML parser. If I was able to load the text string containing the HTML code succesfully, I would be...
5
2351
by: Jack | last post by:
How to quickly build an HTML parser with C#? Does anything like "HTMLParser" exist? Thanks in advance Jack
1
1840
by: Aaron Gray | last post by:
I am looking for an HTML parser that will parser malformed HTML Netscape bookmarks.html files. Ideally it will work with callbacks. Many thanks in advance, Aaron
0
7947
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
7880
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8255
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
6665
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...
1
5739
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5413
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3903
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1486
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1217
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.