Passed
Push — master ( 6e5e3f...9ae0fc )
by dai
01:41
created

school_api.client.api.utils.get_alert_tip()   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
import re
3
from bs4 import BeautifulSoup
4
5
6
def get_alert_tip(html):
7
    ''' 获取页面提示信息 '''
8
    tips = re.findall(r">alert\(\'(.*?)\'", html)
9
    if tips:
10
        return tips[0]
11
12
13
def get_view_state_from_html(html):
14
    ''' 获取 __VIEWSTATE 值 '''
15
    pre_soup = BeautifulSoup(html, "html.parser")
16
    view_state = pre_soup.find(
17
        attrs={"name": "__VIEWSTATE"})['value']
18
    return view_state
19