Найти - Пользователи
Полная версия: Как с помощю регулялки выдернуть значение из переменой javascript
Начало » Python для новичков » Как с помощю регулялки выдернуть значение из переменой javascript
1
agryn
В html странице есть куски с javascript, подскажите как например выдернуть значение переменой window.authHash
html-код
  <script type="text/javascript">
 window.appId = 1234567;
window.authHash = 'data1';
window.authUrl = 'http://site.com/example.php';
createButton(ge('auth_user'), function() {
  if (window.noAuth)
  </script>
html-код
тоесть результатом должно быть data1
Ed
import re

html = """
...
window.authHash = 'data1';
window.authUrl = 'http://site.com/example.php';
createButton(ge('auth_user'), function() {
...
"""

print re.search("window.authHash = '([^']+)", html).group(1)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB