python
1import requests 2import re 3from bs4 import BeautifulSoup 4 5url = "https://search.nifty.com/imagesearch/search?select=1&q=%s&ss=up" 6keyword = "猫" 7r = requests.get(url%(keyword)) 8soup = BeautifulSoup(r.text,'lxml') 9imgs = soup.find_all('img',src=re.compile('^https://msp.c.yimg.jp/yjimage')) 10for img in imgs: 11 print(img['src'])
サンプルコードを見ながら打ち込んでいたんですけど上記の「%」の使いかたが分からないんで教えてください
python
1r = requests.get(url%(keyword))
出力
python
1'https://search.nifty.com/imagesearch/search?select=1&q=猫&ss=up'
初心者ですが簡単に説明お願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。