#加载所需库
import requests
from bs4 import BeautifulSoup
#Nature
# 发起HTTP请求获取网页内容
url = 'https://www.nature.com/nature/volumes/619/issues/7971'
response = requests.get(url)
html_content = response.text
# 使用BeautifulSoup解析网页内容,指定解析器为html.parser
soup = BeautifulSoup(html_content, 'html.parser')
# 假设我们想提取网页中所有的标题文本
titles = soup.find_all('h3')
# 创建一个文件并将标题写入文件,去除空行
with open('nature_titles.txt', 'w', encoding='utf-8') as file:
for title in titles:
title_text = title.text.strip() # 去除标题两端的空白字符
if title_text: # 检查标题是否为空
file.write(title_text + '\n')
print("标题已保存到文件 nature_titles.txt")
得到的结果如下:
Editorial
ChatGPT is a black box: how AI research can break it open
The United Kingdom needs to welcome international researchers to thrive
World View
I’ve witnessed the wonders of the deep sea. Mining could destroy them
Saving tens of millions of children a year from the effects of lead poisoning is a surprisingly solvable problem
Research Highlights
A lethal fungal infection gets a hand from the body’s own defences
Ben Franklin: founding father of anti-counterfeiting techniques
How much snow is on Mount Everest? Scientists climbed it to find out
Nothing strange about this pentaquark’s ‘strangeness’
News
As COVID-19 cases rose, so did diabetes — no one knows why
The true cost of science’s language barrier for non-native English speakers
Had COVID but no symptoms? You might have this genetic mutation
Oil from the Amazon? Proposal to drill at river’s mouth worries researchers
Can India’s new billion-dollar funding agency boost research?
Alzheimer’s drug donanemab helps most when taken at earliest disease stage, study finds
Cell ‘atlases’ offer unprecedented view of placenta, intestines and kidneys
Deep-sea mining could soon be approved — how bad is it?
Features
ChatGPT broke the Turing test — the race is on for new ways to assess AI
Book Review
How a scholarly spat shaped a century of genetic research
Obituary
Harald zur Hausen, virologist who linked viruses to cancer (1936–2023)
Comment
Shade is an essential solution for hotter cities
Correspondence
No-pay publishing: use institutional repositories
Africa: a new dawn for local vaccine manufacture
Pangenomics: prioritize diversity in collaborations
Data sharing: putting Nature’s policy to the test
Feature
Pack up the parachute: why global north–south collaborations need to change
Where I Work
I sample Antarctica’s seaweed to improve human health
News & Views
Heat-assisted imaging enables day-like visibility at night
Dynamics of protein droplets revealed by bridging multiple scales
Long La Niña events could rise in frequency as the planet warms
A sustainable way to control the parasitic disease schistosomiasis
Sixty years since the report of global lead pollution
Perspective
CAR T therapy beyond cancer: the evolution of a living drug
Articles
A massive quiescent galaxy at redshift 4.658
Spectroscopic identification of water emission from a main-belt comet
Diverse organic-mineral associations in Jezero crater, Mars
Spin state and deep interior structure of Mars from InSight radio tracking
Generation of genuine entanglement up to 51 superconducting qubits
Heat-assisted detection and ranging
Femtosecond proton transfer in urea solutions probed by X-ray spectroscopy
Fluidic self-assembly for MicroLED displays by controlled viscosity
Accelerating the energy transition towards photovoltaic and wind in China
The social value of offsets
Increased occurrences of consecutive La Niña events under global warming
A planetary health innovation for disease, food and water challenges in Africa
Indirect effects shape species fitness in coevolved mutualistic networks
Cancer aneuploidies are shaped primarily by effects on tumour fitness
Spatially resolved multiomics of human cardiac niches
Hepatitis C virus RNA is 5′-capped with flavin adenine dinucleotide
PLSCR1 is a cell-autonomous defence factor against SARS-CoV-2 infection
A framework for individualized splice-switching oligonucleotide therapy
Gut microbial fatty acid isomerization modulates intraepithelial T cells
Remote neuronal activity drives glioma progression through SEMA4F
p53 governs an AT1 differentiation programme in lung cancer suppression
KRAS(G12D) drives lepidic adenocarcinoma through stem-cell reprogramming
Complementary Alu sequences mediate enhancer–promoter selectivity
Extreme dynamics in a biomolecular condensate
Matters Arising
Re-evaluating evidence for adaptive mutation rate variation
Reply to: Re-evaluating evidence for adaptive mutation rate variation
Author Correction: GWAS and meta-analysis identifies 49 genetic variants underlying critical COVID-19
Disaster preparedness
Quick links
About Nature Portfolio
Discover content
Publishing policies
Author & Researcher services
Libraries & institutions
Advertising & partnerships
Career development
Regional websites