beautifulsoupを使用すると、サイトのhtmlコードを取得できます。
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
beautifulsoupを使用してヘッドタグ内body {background-color:#b0c4de;}
にこの行を追加するにはどうすればよいですか?
Pythonコードは次のとおりです。
#!/usr/bin/python
import cgi, cgitb, urllib2, sys
from bs4 import BeautifulSoup
site = "www.example.com"
page = urllib2.urlopen(site)
soup = BeautifulSoup(page)