Hi,
Im having an issue with HTMLParser, the getpos() funtion sometimes
returns things like :
(1, 1247)
(1, 2114)
(1, 2168)
(1, 2228)
(1, 2295)
(1, 2382)
(1, 2441)
(1, 2963)
(1, 3040)
i guess this is because the HTMLParser has not correctly parsed the
newline characters in the string fed to it... is there a workaround
for this, without checking the string every time i feed it some data? 3 1930
dysmas wrote:
Hi,
Im having an issue with HTMLParser, the getpos() funtion sometimes
returns things like :
(1, 1247)
(1, 2114)
(1, 2168)
(1, 2228)
(1, 2295)
(1, 2382)
(1, 2441)
(1, 2963)
(1, 3040)
i guess this is because the HTMLParser has not correctly parsed the
newline characters in the string fed to it... is there a workaround
for this, without checking the string every time i feed it some data?
Have you verified that these results aren't correct? There is no
requirements for newlines in HTML, and some computer-generated pages
don't bother to insert them.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
Steve,
thanks for reply
there are newlines present, it looks like the files in question are
from a mac, (my text editor tells me they are UTF8 & use CR for
marking newlines)
Cheers
On Jul 4, 1:47 pm, rokadvertis...@ googlemail.com wrote:
Steve,
thanks for reply
there are newlines present, it looks like the files in question are
from a mac, (my text editor tells me they are UTF8 & use CR for
marking newlines)
Cheers
d0h,
f = open(this_file, "U")
^^^^
\ this fixed it
cheers anyway ;) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Adonis |
last post by:
When parsing my html files, I use handle_pi to capture some embedded python
code, but I have noticed that in the embedded python code if it contains
html, HTMLParser will parse it as well, and thus causes an error when I exec
the code, raises an EOL error. I have a work around for this as I use
different set of characters rather that <tag> use something like (tag) then
revert it back to <tag> via another function, I was wondering if there...
|
by: Sean Cody |
last post by:
I'm trying to take a webpage that has a nxn table of entries (bus times) and
convert it to a 2D array (list of lists). Initially this was simple but I
need to be able to access whole 'columns' of data so the 2D array cannot be
sparse but in the HTML file I'm parsing there can be sparse entries which
are repsented in the table as   entities. The sparse output breaks my
ability to use entire columns and have entries correspond properly....
|
by: Kevin T. Ryan |
last post by:
Hi all -
I'm somewhat new to python (about 1 year), and I'm trying to write a program
that opens a file like object w/ urllib.urlopen, and then parse the data by
passing it to a class that subclasses HTMLParser.HTMLParser. On the web
page, however, there is javascript - and I think that is causing an error
in parsing the data. Here's the error:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
|
by: Rajarshi Guha |
last post by:
Hi,
I have some HTML that looks essentially consists of a series of <div>'s
and each <div> having one of two classes (tnt-question or tnt-answer).
I'm using HTMLParser to handle the tags as:
class MyHTMLParser(HTMLParser.HTMLParser):
def handle_starttag(self, tag, attrs):
if len(attrs) == 1:
cls,whichcls = attrs
|
by: Joe Johnson |
last post by:
Greetings,
I just did a fresh install of Solaris 10 on Sparc. The OS ships with
perl_5.8.4. When I run some of my scripts that run fine on Linux, I get
this:
IO::Seekable::getpos missing at /usr/local/lib/perl5/5.8.6/FileHandle.pm
line 59.
Compilation failed in require at
/home/steve/Development/Tools/common/putil/Eq/Util/FileHandleObj.pm line 6.
| |
by: Lawrence D'Oliveiro |
last post by:
I've been using HTMLParser to scrape Web sites. The trouble with this
is, there's a lot of malformed HTML out there. Real browsers have to be
written to cope gracefully with this, but HTMLParser does not. Not only
does it raise an exception, but the parser object then gets into a
confused state after that so you cannot continue using it.
The way I'm currently working around this is to do a dummy pre-parsing
run with a dummy...
|
by: Kenneth McDonald |
last post by:
I'm writing a program that will parse HTML and (mostly) convert it to
MediaWiki format. The two Python modules I'm aware of to do this are
HTMLParser and htmllib. However, I'm currently experiencing either real
or conceptual difficulty with both, and was wondering if I could get
some advice.
The problem I'm having with HTMLParser is simple; I don't seem to be
getting the actual text in the HTML document. I've implemented the
do_data...
|
by: jonbutler88 |
last post by:
Just writing a simple website spider in python, keep getting these
errors, not sure what to do. The problem seems to be in the feed()
function of htmlparser.
Traceback (most recent call last):
File "spider.py", line 38, in <module>
s.crawl(site)
File "spider.py", line 30, in crawl
self.parse(url)
File "spider.py", line 21, in parse
|
by: globalrev |
last post by:
tried all kinds of combos to get this to work.
http://docs.python.org/lib/module-HTMLParser.html
from HTMLParser import HTMLParser
class MyHTMLParser(HTMLParser):
|
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...
|
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...
| |
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |