Пример #1
0
def test_find_multiple(fake_html_1):
    soup = Soup(fake_html_1)
    result = soup.find("div", {"class": "baz"})
    assert len(result) == 2
    assert str(result[1]) == '<div class="baz">Oh No!</div>'
Пример #2
0
def test_find_text(fake_html_1):
    soup = Soup(fake_html_1)
    result = soup.find("p", {"id": "blarg"})
    assert result.text == "Try for 2"
Пример #3
0
def test_find_first(fake_html_1):
    soup = Soup(fake_html_1)
    result = soup.find("p", mode="first")
    assert str(result) == "<p>'IDK!'</p>"
Пример #4
0
def test_find_with_attrs(fake_html_1):
    soup = Soup(fake_html_1)
    result = soup.find("p", {"id": "blarg"})
    assert str(result) == '<p id="blarg">Try for 2</p>'
Пример #5
0
def test_find_no_match_auto(fake_html_1):
    soup = Soup(fake_html_1)
    result = soup.find("a", mode="auto")
    assert result == None
Пример #6
0
def test_find(fake_html_1):
    soup = Soup(fake_html_1)
    result = soup.find("span")
    assert str(result) == "<span>Hi</span>"
Пример #7
0
def test_find_no_match_first(fake_html_1):
    soup = Soup(fake_html_1)
    result = soup.find("a", mode="first")
    assert result == None
Пример #8
0
def test_find_no_match_all(fake_html_1):
    soup = Soup(fake_html_1)
    result = soup.find("a", mode="all")
    assert result == []
Пример #9
0
def test_find_mutliple_imgs(fake_html_3):
    soup = Soup(fake_html_3)
    result = soup.find("img")
    assert result[1].attrs["src"] == "bye.jpg"
Пример #10
0
def test_remove_tags(fake_html_4):
    soup = Soup(fake_html_4)
    result = soup.remove_tags()
    assert (
        result ==
        "I like soup and I really like cold soup I guess hot soup is okay too")
Пример #11
0
def test_find_nested_empty_tag(fake_html_3):
    soup = Soup(fake_html_3)
    result = soup.find("a", {"class": "foo"})
    assert len(result) == 2
Пример #12
0
def test_find_strict(fake_html_2):
    soup = Soup(fake_html_2)
    result = soup.find("div", {"class": "foo"}, strict=True, mode="all")
    assert len(result) == 1
Пример #13
0
from gazpacho import get
from gazpacho import Soup
import pandas as pd
import time

position = 'F'

base = f'https://www.cbssports.com/fantasy/hockey/stats'
url = f'{base}/{position}/2019/restofseason/projections/'
html = get(url)
soup = Soup(html)
# HTML: <tr class="TableBase-bodyTr ">
rows = soup.find('tr', {'class': 'TableBase-bodyTr '})
row = rows[0]
print(row)
Пример #14
0
def make_soup(url):
    html = get(url)
    soup = Soup(html)
    return soup
Пример #15
0
def make_soup(query, page=1):
    params = {'q': query, 'commit': 'Search', 'page': page}
    html = get(URL, params)
    soup = Soup(html)
    return soup