0

Hello... I have problem with regex, I want to get the tables from another site... the regex is re.compile(r'<table.*?>(.*?)</table>') but when I get the tables I don't know how to return the value into the tables.

#html = the page
tbl = re.compile(r'<table.*?>(.*?)</table>')
return tbl.sub('', html) #return html without <table>...</table>
# how to return the value only of <table> tags... without the other tags ?

Thanks.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Krstevski
0

Hello... I have problem with regex, I want to get the tables from another site... the regex is re.compile(r'<table.*?>(.*?)</table>') but when I get the tables I don't know how to return the value into the tables.

#html = the page
tbl = re.compile(r'<table.*?>(.*?)</table>')
return tbl.sub('', html) #return html without <table>...</table>
# how to return the value only of <table> tags... without the other tags ?

Thanks.

I suggest

the_list = tbl.findall(html)

There is also finditer which returns a sequence of match objects.

0

I suggest

the_list = tbl.findall(html)

There is also finditer which returns a sequence of match objects.

Thanks man, it works :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.