日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

Coursera课程Python for everyone:Quiz: Reading Web Data From Python

發布時間:2025/3/21 python 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Coursera课程Python for everyone:Quiz: Reading Web Data From Python 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Reading Web Data From Python

8?試題

1.?

Which of the following Python data structures is most similar to the value returned in this line of Python:

x = urllib.urlopen('http://www.py4inf.com/code/romeo.txt')

dictionary

regular expression

file handle

socket

list

2.?

In this Python code, which line actually reads the data?

import socket mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) mysock.connect(('www.py4inf.com', 80)) mysock.send('GET http://www.py4inf.com/code/romeo.txt HTTP/1.0\n\n') while True:data = mysock.recv(512)if ( len(data) < 1 ) :breakprint data mysock.close()

mysock.recv()

socket.socket()

mysock.close()

mysock.connect()

mysock.send()

3.?

Which of the following regular expressions would extract the URL from this line of HTML:

<p>Please click <a href="http://www.dr-chuck.com">here</a></p>

href="(.+)"

href=".+"

http://.*

<.*>

4.?

In this Python code, which line is most like the open() call to read a file:

import socket mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) mysock.connect(('www.py4inf.com', 80)) mysock.send('GET http://www.py4inf.com/code/romeo.txt HTTP/1.0\n\n') while True:data = mysock.recv(512)if ( len(data) < 1 ) :breakprint data mysock.close()

mysock.connect()

import socket

mysock.recv()

mysock.send()

socket.socket()

5.?

Which HTTP header tells the browser the kind of document that is being returned?

Content-Type:

Document-Type:

HTML-Document:

ETag:

Metadata:

6.?

What should you check before scraping a web site?

That the web site supports the HTTP GET command

That the web site only has links within the same site

That the web site returns HTML for all pages

That the web site allows scraping

7.?

What is the purpose of the BeautifulSoup Python library?

It repairs and parses HTML to make it easier for a program to understand

It animates web operations to make them more attractive

It builds word clouds from web pages

It optimizes files that are retrieved many times

It allows a web site to choose an attractive skin

8.?

What ends up in the "x" variable in the following code:

html = urllib.urlopen(url).read() soup = BeautifulSoup(html) x = soup('a')

A list of all the anchor tags (<a..) in the HTML from the URL

True if there were any anchor tags in the HTML from the URL

All of the externally linked CSS files in the HTML from the URL

All of the paragraphs of the HTML from the URL

總結

以上是生活随笔為你收集整理的Coursera课程Python for everyone:Quiz: Reading Web Data From Python的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。