|
沼田/リンク/2026-01-02?は空です。 | |||||||||||||||||||||||||||||||||||||||||||||||||
インライン要素asgsdhgjkashgjkdhaslgっっっっっっっっっs
| データ | データ |
#ee7800 アンカーの設定[#8桁の英数字]
#ref(): File not found: "crawl.png" at page "沼田/リンク"
| インライン要素 |
| インライン要素 |
| aaaaaaa | aaaaaaaa |
| 1 | 2 | |
| 3 | 4 | |
| 5 | ||
| ああ |
#pre{{
import requests
import lxml.html
def main():
"""
クローラーのメインの処理
"""
response = requests.get('https://gihyo.jp/dp')
#scrape_list_page()関数を呼び出し、ジェネレーターイテレーターを取得する
urls = scrape_list_page(response)
for url in urls: #ジェネレーターイテレーターはlistなどと同様に繰り返し可能
print(url)
def scrape_list_page(response):
"""
一覧ページのresponseから詳細ページのURLを抜き出すジェネレーター関数
"""
root = lxml.html.fromstring(response.content)
root.make_links_absolute(response.url)
for a in root.cssselect('#listBook a[itemprop="url"]'):
url = a.get('href')
yield url #yield文でジェネレーターイテレーターの要求を返す
if __name__ == '__main__':
main()
}}
!#versionlist
@using WebApplication2 @{
Score s = new Score(0, 80);
List<Score> list = new List<Score>();
Random rand = new Random();
for (int i = 0; i < 100; i++)
{
list.Add(new Score(i, rand.Next(0, 101)));
}
} @using WebMatrix.Data @{
var scoredb = Database.Open("scoredb");
var data = scoredb.Query("select * from Score");
}
!DOCTYPE html>
html>
head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <meta charset="utf-8" /> <style type="text/css"> h1.wai { color: red; }
h1.hoge {
color: blue;
}
li.n1 {
color: yellow;
}
li.n2 {
color: gold;
}
li.n3 {
color: skyblue;
}
li.o50 {
color: red;
}
li.u50 {
color: blue;
}
</style>
/head>
body>
@foreach(var a in data) { <p>@a.id:@a.score</p> } <form action="add.cshtml" method ="post"> <input type="text" name="id" /> <input type="text" name="score" /> <input type="submit" /> </form> <h1 class="wai">わーーーーーい</h1> <h1 class="hoge">ほげーーーー</h1> <p>@s.id:@s.score</p>
<p>UL LIを使って、箇条書きで表示してください</p>
<p>CSSを使って、50点以上は赤、未満は青で表示してください</p>
@{
foreach (Score ss in list)
{
if (@ss.score >= 50)
{
<ul>
<li class="o50">
@ss.id @ss.score
</li>
</ul>}
else
{<ul>
<li class="u50">
@ss.id @ss.score
</li>
</ul>
}
}
}
<p>段落です</p>
<ul>
<li class="n1">一番目</li>
<li class="n2">二番目</li>
<li class="n3">三番目</li>
</ul>
/body>
/html>