warn-scraper 1.2.162.dev0__py3-none-any.whl → 1.2.164.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- warn/scrapers/tx.py +21 -10
- {warn_scraper-1.2.162.dev0.dist-info → warn_scraper-1.2.164.dev0.dist-info}/METADATA +1 -1
- {warn_scraper-1.2.162.dev0.dist-info → warn_scraper-1.2.164.dev0.dist-info}/RECORD +9 -9
- {warn_scraper-1.2.162.dev0.dist-info → warn_scraper-1.2.164.dev0.dist-info}/scm_version.json +2 -2
- {warn_scraper-1.2.162.dev0.dist-info → warn_scraper-1.2.164.dev0.dist-info}/WHEEL +0 -0
- {warn_scraper-1.2.162.dev0.dist-info → warn_scraper-1.2.164.dev0.dist-info}/entry_points.txt +0 -0
- {warn_scraper-1.2.162.dev0.dist-info → warn_scraper-1.2.164.dev0.dist-info}/licenses/LICENSE +0 -0
- {warn_scraper-1.2.162.dev0.dist-info → warn_scraper-1.2.164.dev0.dist-info}/scm_file_list.json +0 -0
- {warn_scraper-1.2.162.dev0.dist-info → warn_scraper-1.2.164.dev0.dist-info}/top_level.txt +0 -0
warn/scrapers/tx.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import logging
|
|
2
|
+
import random
|
|
2
3
|
import re
|
|
3
4
|
import sys
|
|
4
5
|
from pathlib import Path
|
|
6
|
+
from time import sleep
|
|
5
7
|
|
|
8
|
+
import niquests as requests
|
|
6
9
|
from bs4 import BeautifulSoup
|
|
7
10
|
from openpyxl import load_workbook
|
|
8
11
|
|
|
@@ -32,22 +35,23 @@ def scrape(
|
|
|
32
35
|
|
|
33
36
|
Returns: the Path where the file is written
|
|
34
37
|
"""
|
|
35
|
-
ssl_verify = (
|
|
36
|
-
True # Problems with certificates in November 2024; re-enabled March 2026
|
|
37
|
-
)
|
|
38
|
-
|
|
39
38
|
# Set up the cache
|
|
40
39
|
cache = Cache(cache_dir)
|
|
41
40
|
|
|
42
41
|
# Get the root URL
|
|
43
42
|
url = "https://www.twc.texas.gov/data-reports/warn-notice"
|
|
44
43
|
# pagebin, html = utils.get_with_zyte(url)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
session = requests.Session()
|
|
45
|
+
|
|
46
|
+
page = session.get(url)
|
|
47
|
+
|
|
48
|
+
# page = utils.get_url(
|
|
49
|
+
# url,
|
|
50
|
+
# verify=ssl_verify,
|
|
51
|
+
# user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/999.0.0.0 Safari/537.36",
|
|
52
|
+
# )
|
|
50
53
|
html = page.text
|
|
54
|
+
sleep(random.uniform(2, 4))
|
|
51
55
|
|
|
52
56
|
# Cache it
|
|
53
57
|
cache.write("tx/source.html", html)
|
|
@@ -86,7 +90,14 @@ def scrape(
|
|
|
86
90
|
# download the excel file
|
|
87
91
|
year = _get_year(href)
|
|
88
92
|
ext = _get_ext(href)
|
|
89
|
-
excel_path = cache.download(f"tx/{year}{ext}", data_url, verify=ssl_verify)
|
|
93
|
+
# excel_path = cache.download(f"tx/{year}{ext}", data_url, verify=ssl_verify)
|
|
94
|
+
r = session.get(data_url)
|
|
95
|
+
excel_path = cache_dir / f"tx/{year}{ext}"
|
|
96
|
+
|
|
97
|
+
with open(excel_path, "wb") as outfile:
|
|
98
|
+
outfile.write(r.content)
|
|
99
|
+
sleep(random.uniform(2, 4))
|
|
100
|
+
|
|
90
101
|
# filename = f"tx/{year}{ext}"
|
|
91
102
|
# excelbin, exceltext = utils.get_with_zyte(data_url)
|
|
92
103
|
# excel_path = cache.write_binary(filename, excelbin)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: warn-scraper
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.164.dev0
|
|
4
4
|
Summary: Command-line interface for downloading WARN Act notices of qualified plant closings and mass layoffs from state government websites
|
|
5
5
|
Author-email: Big Local News <biglocalnews@stanford.edu>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -48,17 +48,17 @@ warn/scrapers/ri.py,sha256=EUyLy59eNiYHqiJR8C0YcJrZtp09KyVc45AFD0_Uc0U,4497
|
|
|
48
48
|
warn/scrapers/sc.py,sha256=p3kscSNSW9C8C5QaSUbCAo6XibgB7G2iH6zaMH7Mnsc,4819
|
|
49
49
|
warn/scrapers/sd.py,sha256=_4R19Ybzsyx1PvcWV3_laJmJ3etrwVGfhNEQm6njwoA,1904
|
|
50
50
|
warn/scrapers/tn.py,sha256=i1H7c09Ea3CDrTXqqRMLBMPT_34QtGA0-x7T8rm_j5Q,2945
|
|
51
|
-
warn/scrapers/tx.py,sha256=
|
|
51
|
+
warn/scrapers/tx.py,sha256=y_pRNuTzaQBkHpRKJXA5Fw8ZsjyPJIVElcwGinlf9wk,5594
|
|
52
52
|
warn/scrapers/ut.py,sha256=iUh38YIjbvv5MyyKacsiZNe8KjfdBeDaOf-qMQEF_kc,2245
|
|
53
53
|
warn/scrapers/va.py,sha256=7Nle7qL0VNPiE653XyaP9HQqSfuJFDRr2kEkjOqLvFM,11269
|
|
54
54
|
warn/scrapers/vt.py,sha256=d-bo4WK2hkrk4BhCCmLpEovcoZltlvdIUB6O0uaMx5A,1186
|
|
55
55
|
warn/scrapers/wa.py,sha256=UXdVtHZo_a-XfoiyOooTRfTb9W3PErSZdKca6SRORgs,4282
|
|
56
56
|
warn/scrapers/wi.py,sha256=ClEzXkwZbop0W4fkQgsb5oHAPUrb4luUPGV-jOKwkcg,4855
|
|
57
|
-
warn_scraper-1.2.
|
|
58
|
-
warn_scraper-1.2.
|
|
59
|
-
warn_scraper-1.2.
|
|
60
|
-
warn_scraper-1.2.
|
|
61
|
-
warn_scraper-1.2.
|
|
62
|
-
warn_scraper-1.2.
|
|
63
|
-
warn_scraper-1.2.
|
|
64
|
-
warn_scraper-1.2.
|
|
57
|
+
warn_scraper-1.2.164.dev0.dist-info/licenses/LICENSE,sha256=ZV-QHyqPwyMuwuj0lI05JeSjV1NyzVEk8Yeu7FPtYS0,585
|
|
58
|
+
warn_scraper-1.2.164.dev0.dist-info/METADATA,sha256=9uVo6pFhNTkENUnJQlk0sAEmSydHUtpIqgW0YYy8XoA,1780
|
|
59
|
+
warn_scraper-1.2.164.dev0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
60
|
+
warn_scraper-1.2.164.dev0.dist-info/entry_points.txt,sha256=poh_oSweObGlBSs1_2qZmnTodlOYD0KfO7-h7W2UQIw,47
|
|
61
|
+
warn_scraper-1.2.164.dev0.dist-info/scm_file_list.json,sha256=SBROd7oEfcspIMl6v7yfGzQd2rkWxybkiIXopuTQVL0,4120
|
|
62
|
+
warn_scraper-1.2.164.dev0.dist-info/scm_version.json,sha256=o9jp_dH_h9sOfOdsitbgUoIVY45dh_C8KFlgYCGZeqI,161
|
|
63
|
+
warn_scraper-1.2.164.dev0.dist-info/top_level.txt,sha256=dZfms6N3kqVXufiPOo7YqOrAcUtYfNH_oyGvYUk9FB4,5
|
|
64
|
+
warn_scraper-1.2.164.dev0.dist-info/RECORD,,
|
|
File without changes
|
{warn_scraper-1.2.162.dev0.dist-info → warn_scraper-1.2.164.dev0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{warn_scraper-1.2.162.dev0.dist-info → warn_scraper-1.2.164.dev0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{warn_scraper-1.2.162.dev0.dist-info → warn_scraper-1.2.164.dev0.dist-info}/scm_file_list.json
RENAMED
|
File without changes
|
|
File without changes
|