EADST

Extract Webpage Information with Python

Here is the python program to extract webpage information with BeautifulSoup and save the data in a CSV file.

from bs4 import BeautifulSoup
import urllib.request
import pandas as pd

url = 'file:///Users/xd/Desktop/ieee/Region_5_Student_Branch_Counselors_and_Chairs.htm'
save_file = 'ieee_info_1'
html = urllib.request.urlopen(url).read()

soup = BeautifulSoup(html, "html.parser")

universities = soup.find_all('div', class_='spoName bullet pad-t15')
people = soup.find_all('div', class_='roster-results')

for u, p in zip(universities, people):
    info = p.find_all('p')
    university = u.get_text()
    name = info[0].get_text()
    if name == 'Position Vacant':
        continue
    title = info[2].get_text()
    address = info[3].get_text() + ', ' + info[4].get_text()
    email = info[-1].get_text()[7:]

    content = [[university, name, title, address, email]]
    list_name = ['university', 'name', 'title', 'address', 'email']
    data = pd.DataFrame(columns=list_name, data=content)
    data.to_csv("{}.csv".format(save_file), mode='a', index=False, header=False, encoding='utf-8')
About Me
XD
Goals determine what you are going to be.
Category
标签云
Qwen2 Freesound Website WebCrawler Template BF16 第一性原理 CLAP Markdown C++ transformers SQL 阿里云 v0.dev Vim XML Input Pillow printf Docker CV Hotel Translation LaTeX Hungarian tar Image2Text Git Knowledge MD5 uwsgi PyCharm Rebuttal Claude git-lfs InvalidArgumentError Jetson HaggingFace mmap GIT SVR scipy DeepSeek Excel tqdm CEIR Conda Tensor Heatmap Anaconda Clash Transformers Land RL 多线程 Shortcut Use GGML Data Attention NLTK GPT4 飞书 Algorithm Random QWEN AI ResNet-50 git Search Nginx SPIE TSV Google Interview Paddle Magnet Qwen2.5 TensorRT Card 搞笑 Mixtral JSON 递归学习法 Paper 图标 强化学习 Qwen Windows IndexTTS2 Zip 论文 GPTQ Github FastAPI Miniforge VGG-16 NameSilo Tiktoken ms-swift 论文速读 Base64 Food TensorFlow PDF Distillation Quantization CAM Dataset HuggingFace SAM Math 公式 PyTorch Animate TTS Augmentation CC Diagram Linux Bitcoin EXCEL DeepStream Logo Safetensors Sklearn LeetCode BeautifulSoup FP8 Ubuntu 音频 继承 PDB CTC uWSGI PIP Quantize Plotly SQLite torchinfo Python OCR 版权 Agent Jupyter VSCode 腾讯云 RAR UI YOLO Review UNIX Hilton 净利润 多进程 ModelScope llama.cpp RGB Crawler Streamlit Permission ChatGPT Breakpoint XGBoost Video diffusers Password FP32 FlashAttention Color 云服务器 Bipartite Bert 顶会 CUDA OpenCV ONNX Plate Pandas FP16 报税 Cloudreve 关于博主 Numpy COCO icon Gemma FP64 Web Bin 证件照 Pytorch BTC Baidu Datetime Vmess GoogLeNet LoRA Domain WAN Pickle API hf VPN News LLM Statistics 图形思考法 CSV logger Firewall Disk Ptyhon 签证 Proxy Django Llama NLP v2ray LLAMA 域名 财报 OpenAI Michelin Tracking 算法题
站点统计

本站现有博文333篇,共被浏览916162

本站已经建立2620天!

热门文章
文章归档
回到顶部