Galaxy プリインストール アンインストール

github.com

technastic.com

www.fonearena.com

adb shell pm list packages | cut -d: -f2 | grep xxxxx > list.txt
# au galaxy

adb shell pm uninstall -k --user 0 com.kddi.android.au_wifi_connect2
adb shell pm uninstall -k --user 0 jp.netstar.familysmile
adb shell pm uninstall -k --user 0 com.kddi.android.auinitialsetting

# My au
adb shell pm uninstall -k --user 0 com.kddi.cs.app001

adb shell pm uninstall -k --user 0 com.kddi.selfcare.client
adb shell pm uninstall -k --user 0 com.microsoft.appmanager
adb shell pm uninstall -k --user 0 com.microsoft.skydrive
adb shell pm uninstall -k --user 0 jp.netstar.familysmile

adb shell pm uninstall -k --user 0 com.google.android.videos

adb shell pm list packages | grep com.samsung

adb shell pm uninstall -k --user 0 com.samsung.android.livestickers
adb shell pm uninstall -k --user 0 com.samsung.android.aremoji
adb shell pm uninstall -k --user 0 com.sec.android.mimage.avatarstickers
adb shell pm uninstall -k --user 0 com.samsung.android.arzone
adb shell pm uninstall -k --user 0 com.samsung.android.ardrawing
adb shell pm uninstall -k --user 0 com.samsung.android.game.gamehome

adb shell pm uninstall -k --user 0 com.facebook.services
adb shell pm uninstall -k --user 0 com.facebook.system
adb shell pm uninstall -k --user 0 com.facebook.appmanager

adb shell pm uninstall -k --user 0 com.sec.android.mimage.avatarstickers
adb shell pm uninstall -k --user 0 com.sec.android.app.samsungapps

adb shell pm uninstall -k --user 0 com.samsung.android.app.routines
adb shell pm uninstall -k --user 0 com.samsung.android.visionintelligence
adb shell pm uninstall -k --user 0 com.samsung.android.themestore
adb shell pm uninstall -k --user 0 com.samsung.android.app.spage
adb shell pm uninstall -k --user 0 com.samsung.android.scloud
adb shell pm uninstall -k --user 0 com.samsung.android.ipsgeofence
adb shell pm uninstall -k --user 0 com.sec.android.app.sbrowser
adb shell pm uninstall -k --user 0 com.samsung.android.lool
adb shell pm uninstall -k --user 0 com.samsung.android.service.health

adb shell pm uninstall -k --user 0 com.dsi.ant.plugins.antplus
adb shell pm uninstall -k --user 0 com.dsi.ant.server
adb shell pm uninstall -k --user 0 com.dsi.ant.service.socket
adb shell pm uninstall -k --user 0 com.dsi.ant.sample.acquirechannels

adb shell pm uninstall -k --user 0 com.microsoft.skydrive

某サイトの買取金額のスクレイピング対策の金額をスクレイピング

  1. 買取金額表示用の数字画像を取得
  2. OCRで画像から数字に変換
  3. 切り抜き位置から数字番号取得
  4. 数字に変換

CSSからのパースはじめてした

pypi.org

teratail.com

teratail.com

pip install easyocr
pip install cssutils
import pathlib
from urllib.parse import urljoin

import cssutils
import easyocr
import requests
from bs4 import BeautifulSoup

# スクレイピング

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko"
}


def fetch_soup(url, parser="html5lib"):

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

    soup = BeautifulSoup(r.content, parser)

    return soup


def fetch_file(url, fn):

    p = pathlib.Path(fn)
    p.parent.mkdir(parents=True, exist_ok=True)

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

    with p.open(mode="wb") as fw:
        fw.write(r.content)

    return p

# URLなし
url = ""

soup = fetch_soup(url)

# prettifyで整形されたファイルで保存
with open("test.html", mode="w", encoding="utf-8") as fw:
    fw.write(soup.prettify())

# encrypt-num

css = soup.select_one("div.topic > style").get_text(strip=True)

sheet = cssutils.parseString(css)

img_url = ""

for rule in sheet:
    if rule.type == rule.STYLE_RULE:
        # find property
        for property in rule.style:
            if property.name == "background-image":
                temp = property.value
                img_url = temp.replace("url(", "").replace(")", "")
                break

img_url

link = urljoin(url, img_url)
print(link)

p = fetch_file(link, "encrypt-num.png")


reader = easyocr.Reader(["en"], gpu=False)
result = reader.readtext("encrypt-num.png", detail=0, allowlist="0123456789")[0] + ","

print(result)

for tag in soup.select("div.item.item-thumbnail.item-product-list"):

    title = tag.select_one("h4.item-title").get_text(strip=True)
    print(title)

    for price in tag.select("div.item-price.encrypt-price"):

        number = [
            int(
                int(
                    cssutils.parseStyle(i.get("style"))["background-position"].strip(
                        "-px"
                    )
                )
                / 10
            )
            for i in price.select("span.encrypt-num")
        ]

        print("".join([result[j] for j in number]))

    print("-" * 20)

ワンライナーでテーブルをCSVに変換

papiro.hatenablog.jp

curl -s "https://www.bleague.jp/stats/?tab=1&year=2021" \
| nkf -Wwd \
| xmllint --html --xpath '//table[@id="tbl-player"]//tr' - 2> /dev/null \
| grep -e '<tr class="tips-parent">' -e '<th class="sort' -e '<td class="{sortValue:' -e '<td>[^<>]*</td>' \
| sed 's/<[^<>]*>//g' \
| tr -d ' ' \
| tr "\n" "," \
| sed 's/,順位,選手,チーム,//' \
| sed 's/,,/\n/g' \
| sed '/^$/d'

なんでかカンマだけになるどうも改行コードがだめみたい

sed 's/&#13;//g' 

が機能していないのか

genzouw.com

改行コードが違うのか動かなったので調整

改行コードCRの除去

nkf -Wwd
# 本はこっち
nkf -wLux
sed 's/\r//g'

utf-8の改行\nに変換

sed '/^$/d'

空行削除

各医療機関内の病床の確保状況をシェルで変換

自分で作った

curl -s https://www.mhlw.go.jp/stf/seisakunitsuite/bunya/0000121431_00335.html \
| xmllint --html --xpath '//a[contains(@href,".csv")]/@href' - \
| xargs -n 1 \
| cut -d= -f2 \
| sed 's;^;https://www.mhlw.go.jp/;;' \
| xargs -n 1 curl -L#O

curl -s https://www.mhlw.go.jp/stf/seisakunitsuite/bunya/0000121431_00327.html \
| xmllint --html --xpath 'string(//a[contains(@href,".csv")]/@href)' - \
| sed 's;^;https://www.mhlw.go.jp/;;' \
| xargs -n 1 curl -L#O

cat *.csv | iconv -c -f SHIFT_JIS -t UTF-8 > result

ぱぴろんちゃん さんのコード

# ダウンロードするCSVファイルのURLリスト作成
(
curl -s https://www.mhlw.go.jp/stf/seisakunitsuite/bunya/0000121431_00335.html | xmllint --html --xpath '//a[contains(@href,".csv")]/@href' - 2> /dev/null | xargs -n 1 | cut -d= -f2
curl -s https://www.mhlw.go.jp/stf/seisakunitsuite/bunya/0000121431_00327.html | xmllint --html --xpath 'string(//a[contains(@href,".csv")]/@href)' 2> /dev/null -
) > download/filelist

(
cd download
rm -f *.csv result_head result_body

# CSVファイルのダウンロード
cat filelist | sed 's;^;https://www.mhlw.go.jp/;;' | xargs wget

# 説明文を取り除いて、URLリスト順に連結。ファイル名日付順になってないのに注意。
cat filelist | awk '{print $NF}' FS=/ | xargs awk '22<=FNR{print FILENAME,FNR,$0}' FS=, RS='\r\n' OFS=, ORS='\r\n' |

# 列名の改行を削除して、改行とダブルクォーテーションを削除
awk '{for(i=1;i<=NF;i++){gsub("\n","",$i)}print}'  FS=, RS='\r\n' OFS=, ORS='\r\n' | tr -d '"' |

# 実績日のフォーマットを、固定長のYYYY/MM/DDにする
# 実績日が"44566"のようになってる場合もあるのに注意
awk '$10~/[0-9]+\/[0-9]+\/[0-9]+/{split($10,date,"/");$10=sprintf("%04d/%02d/%02d", date[1], date[2], date[3])}{print}' FS=, RS='\r\n' OFS=, ORS='\r\n' > result_body

# ヘッダー抜き出し
ls *.csv | head -n 1 | xargs awk 'FNR==21{print "ファイル名","ファイル行番号",$0}' FS=, RS='\r\n' OFS=, ORS='\r\n' > result_head
)

# ヘッダーとデータボディを連結
cat download/result_head download/result_body | nkf > result.csv
2> /dev/null

でエラーを破棄が標準出力にでないみたい

{print}は{print $0}と同じ

cat filelist | awk '{print $NF}' FS=/ | xargs awk '22<=FNR{print FILENAME,FNR,$0}' FS=, RS='\r\n' OFS=, ORS='\r\n'

FILENAME 現在処理しているファイルの名前

FNR ファイル別行番号

NF 各行の列数

FS フィールドの区切り

RS レコードの区切り

OFS 出力時のフィールドの区切り(デフォルトは空白)

ORS 出力時のレコードの区切り(デフォルトは改行)

atmarkit.itmedia.co.jp

awk '{for(i=1;i<=NF;i++){gsub("\n","",$i)}print}'  FS=, RS='\r\n' OFS=, ORS='\r\n' | tr -d '"'

gsub 全ての置換対象文字列を置換

sub 最初の置換対象文字列一回のみ置換

tr -d '"' ダブルクォーテーションを削除

ワンライナーでMLSから楽天モバイルのみのCSV作成

www.web-dev-qa-db-ja.com

curl -s https://location.services.mozilla.com/downloads \
| xmllint --html --xpath 'string(/html/body/div/section/ul/li[1]/a/@href)' - \
| xargs -n 1 curl -s \
| gzip -d \
| awk 'BEGIN{FS=","} $1 == "LTE" && $2 == 440 && $3 == 11 {print $0}' > mls_44011.csv

future-architect.github.io

curl -sS https://location.services.mozilla.com/downloads \
| xmllint --html --xpath '/html/body/div/section/div/ul/li/a[contains(@href, "MLS-diff-cell-export")]/@href' - \
| xargs -n 1 \
| cut -d= -f2 \
| xargs -n 1 curl -s \
| gzip -d \
| awk 'BEGIN{FS=","} $1 == "LTE" && $2 == 440 && $3 == 11 {print $0}' > mls_44011.csv

awk 'NR==1 || FNR!=1'

zenn.dev

curl -sS https://location.services.mozilla.com/downloads \
| xmllint --html --xpath 'string(/html/body/div/section/ul/li[1]/a/@href)' - \
| xargs -n 1 curl -s \
| gzip -d \
| awk 'BEGIN{FS=","; OFS=","; print "area,cell,unit,lon,lat,range,samples,created,updated"} ($1 == "LTE" && $2 == 440 && $3 == 11 && $5 >= 188743680 && $5 < 190023680 && $6 != "" && $9 > 0) {print $4,$5,$6,$7,$8,$9,$10,$12,$13}' > mls_44011.csv

ワンライナーでMLSから楽天モバイルのみのCSV作成

www.web-dev-qa-db-ja.com

curl -s https://location.services.mozilla.com/downloads \
| xmllint --html --xpath 'string(/html/body/div/section/ul/li[1]/a/@href)' - \
| xargs -n 1 curl -s \
| gzip -d \
| awk 'BEGIN{FS=","} $1 == "LTE" && $2 == 440 && $3 == 11 {print $0}' > mls_44011.csv