---
# System prepended metadata

title: Crawl Note

---

# Crawl Note

## Installing Packages

```python=
!pip install requests
!pip install bs4
```

## Import Modules

```python=
import requests
from bs4 import BeautifulSoup
```

## Crawl

```python=
url = '網址'
req = request.get(url)
if (req.status_code == 200):
    content = BeautifulSoup(req.text, 'html.parser')
```

## Google Sheet

```python=
from google.colab import auth
import gspread
from google.auth import default
```

```python=
auth.authenticate_user()
creds, _ = default()
gc = gspread.authorize(creds)
```

```python=
sh = gc.open('Sheet_Name')
worksheet = sh.worksheet('Worksheet_Name')
written = 0
for p in p_list:
    cell_list = worksheet.range('A'+str(2+written)+':C'+str(2+written))
    for i in range(len(p)):
        cell_list[i].value = p[i]
    worksheet.update_cells(cell_list)
    written += 1
```