Convert PDF of Go To EAT member stores in Ishikawa prefecture to CSV

Convert PDF of member stores of Ishikawa Go To Eat Campaign to CSV

pip install tabula-py
pip install pandas
pip install beautifulsoup4
pip install requests
from urllib.parse import urljoin

import requests
from bs4 import BeautifulSoup

import pandas as pd
from tabula import read_pdf

url = "https://ishikawa-gotoeat-cpn.com/member_store/"

r = requests.get(url)
r.raise_for_status()

soup = BeautifulSoup(r.content, "html.parser")

dfs = [
    tbl
    for tag in soup.select("p.btn.btn_red.btn_pdf > a")
    for tbl in read_pdf(urljoin(url, tag.get("href")), pages="all", lattice=True)
]

df = pd.concat(dfs).set_axis(["Municipal name", "Store name"], axis=1).reset_index(drop=True)

df.to_csv("ishikawa.csv", encoding="utf_8_sig")

Recommended Posts

Convert PDF of Go To EAT member stores in Ishikawa prefecture to CSV
Convert PDF of list of Go To EAT member stores in Niigata prefecture to CSV
Convert PDF of available stores of Go To EAT in Kagoshima prefecture to CSV
Convert PDF of Kumamoto Prefecture Go To EAT member store list to CSV
Convert PDF of Chiba Prefecture Go To EAT member store list to CSV (command)
Scraping the member stores of Go To EAT in Osaka Prefecture and converting them to CSV
Scraping the list of Go To EAT member stores in Niigata prefecture and converting it to CSV
Convert PDF of Go To Eat Hokkaido campaign dealer list to CSV
Convert PDF of new corona outbreak case in Aichi prefecture to CSV
Convert markdown to PDF in Python
Convert PDF of the progress of the division of labor (trends in insurance dispensing) of the Japan Pharmaceutical Association to CSV
Convert from PDF to CSV with pdfplumber
I want to convert a table converted to PDF in Python back to CSV
The story of creating a store search BOT (AI LINE BOT) for Go To EAT in Chiba Prefecture (1)
Convert PDF of product list containing effective surfactants for new coronavirus to CSV
The story of creating a store search BOT (AI LINE BOT) for Go To EAT in Chiba Prefecture (2) [Overview]
Batch convert PSD files in directory to PDF
[Python] Convert PDF text to CSV page by page (2/24 postscript)
Convert the image in .zip to PDF with Python
Convert PDF of the situation of people infected in Tokyo with the new coronavirus infection of the Tokyo Metropolitan Health and Welfare Bureau to CSV
Batch convert all xlsx files in the folder to CSV files
Django Changed to save lots of data in one go
Convert SDF to CSV quickly
Sphinx extension to arbitrarily convert text in pre-processing of document generation
Convert files written in python etc. to pdf with syntax highlighting
Convert a large number of PDF files to text files using pdfminer
Create a function to get the contents of the database in Go
Memorandum (in openpyxl ① copy and paste from another book ② refer to the comparison table)
Steps to change table and column names in your Django model at the same time
Scraping the member stores of Go To EAT in Osaka Prefecture and converting them to CSV