两个并列不定式第二个不定式要不要带to

请问是 to do and do 还是 to do and to do? 如果把 and 换成 or 呢?后面一个不定式要不要带 to?

最佳答案
■当两个带 to 不定式由 and 或 or 连接时,第二个不定式符号常可省略。例如:

I intend to call on him and discuss this question again.

Christina hardly knew whether to laugh or cry.

She asked me to telephone or wire to her on Monday.

■若两个并列的‍带不定式有对比含义,第二个不定式符号便不能省略。例如:

To be or not to be, that is the question. 存在还是毁灭,是个要考虑的问题。

I haven’t decided to go home or to stay at school this summer .

■不用并列连词的情况下,第二个不定式符号也不能省略。例如:

Please go to the seaside to swim, to get suntanned.

He likes to stay with the peasants, to work in the fields with them.

■当三个或三个以上带不定式构成排比结构时,所有的不定式符号均须保留。例如:

Read not to contradict or confute; nor to believe and take for granted; not to find talk and discourse; but to weigh and consider.

(以上摘自《新编高级英语语法》,章振邦主编,上海外语教育出版社2012年12月第1版)

使用Selenium在并列标签中爬取第二个内容可以通过以下步骤实现: 1. **安装Selenium和浏览器驱动**:首先,确保你已经安装了Selenium库和相应的浏览器驱动(例如ChromeDriver)。 ```bash pip install selenium ``` 2. **导入必要的库**:在你的Python脚本中导入Selenium库和其他必要的库。 ```python from selenium import webdriver from selenium.webdriver.common.by import By import time ``` 3. **初始化WebDriver**:初始化WebDriver并打开目标网页。 ```python # 初始化WebDriver(以Chrome为例) driver = webdriver.Chrome(executable_path='path/to/chromedriver') # 打开目标网页 driver.get('http://example.com') ``` 4. **定位并列标签**:使用XPath或其他定位方法来找到并列的标签。 ```python # 等待页面加载 time.sleep(3) # 定位并列标签 elements = driver.find_elements(By.XPATH, '//tag_name[@attribute="value"]') ``` 5. **提取第二个内容**:从定位到的标签中提取第二个内容。 ```python # 提取第二个内容 second_element = elements[1] second_content = second_element.text print(second_content) ``` 6. **关闭WebDriver**:完成操作后,关闭WebDriver。 ```python # 关闭WebDriver driver.quit() ``` 完整的示例代码如下: ```python from selenium import webdriver from selenium.webdriver.common.by import By import time # 初始化WebDriver(以Chrome为例) driver = webdriver.Chrome(executable_path='path/to/chromedriver') # 打开目标网页 driver.get('http://example.com') # 等待页面加载 time.sleep(3) # 定位并列标签 elements = driver.find_elements(By.XPATH, '//tag_name[@attribute="value"]') # 提取第二个内容 second_element = elements[1] second_content = second_element.text print(second_content) # 关闭WebDriver driver.quit() ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值