У меня есть вот такой код:
import re
import urllib.request
def main():
pattern = re.compile(r"(?P<Block><div id=\"entryContent\">.*)")
data = urllib.request.urlopen("http://www.oxfordlearnersdictionaries.com/"
"definition/english/hello").read().decode()
result = pattern.search(data)
print(result.group("Block"))
main()
Результат:
<div id="entryContent"><div xmlns="http://www.w3.org/1999/xhtml" class="entry" sk="hello11" id="hello_1"><ol class="h-g" id="hello_1__1"><div class="top-container"><div class="top-g" id="hello_1__2">
По моему пониманию, я должен был получить текст начиная c "<..." до окончания. Специально поставил ".*". Но, почему-то, анализ текста прерывается почти сразу и я получаю только малую часть. Почему там может быть?