<asp:TextBox..>与<input type=text..>区别

<asp:TextBox..>与<input type=text..>区别

在研究suggestbox控件时,若是使用<asp:TextBox ID="txt_account" runat="server"></asp:TextBox>,

则调用 $("#txt_account").suggestboxSeller();无法成功,应改成 $("#<%=txt_account.ClientID%>").suggestboxSeller();

<asp:TextBox...>是服务器控件
<input type=text...>是客户端控件

在服务器端运行的控件在客户端显示的ID是不可预测的,要用其ID写写clicentid才可以。

<asp:TextBox...> 最终还是解析为<input type=text...> HTML

<asp:textbox>在页面的生命周期的最后一步是要render成html<input>的
因为浏览器只解析html语言的元素
只要你保证render后的html元素的id对应就可以

在JS里调用没必要用服务器控件

若要用<asp:TextBox...>

<asp:TextBox id="TextBox1" runat="server'></asp:TextBox>
js:
combobox('<%=TextBox1.ClientID%>',lav,lat)


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
修改代码如下: ``` import requests from bs4 import BeautifulSoup import os headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' } total_pages = 20 # 遍历爬取页面 for i in range(2195306, 3000000): url = f"https://www.bernama.com/bm/news.php?id={i}" res = requests.get(url, headers=headers) soup = BeautifulSoup(res.text, "html.parser") # 获取需要写入的文本内容 div = soup.find("div", {"class": "col-12 mt-3 text-dark text-justify"}) if not div: print(f"id{i} has no data, skipped.") continue text = div.text # 保存到txt文件 file = str(i) + ".txt" with open(file, "w", encoding="utf-8") as f: f.write(text) print(f"id {i} saved successfully.") print("All pages saved successfully.") ``` 下面是将获取的数据分别保存到txt中,每个txt命名为1~250的代码: ``` import requests from bs4 import BeautifulSoup import os headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' } total_pages = 20 # 遍历爬取页面 for i in range(1, 251): url = f"https://www.example.com/page={i}" res = requests.get(url, headers=headers) soup = BeautifulSoup(res.text, "html.parser") # 获取需要写入的文本内容 divs = soup.find_all("div", {"class": "content"}) for j, div in enumerate(divs): text = div.text # 保存到txt文件 file = str(i) + "_" + str(j+1) + ".txt" with open(file, "w", encoding="utf-8") as f: f.write(text) print(f"Page {i}, article {j+1} saved successfully.") print("All pages saved successfully.") ``` 其中,我们假设要爬取的网站为 example.com,每页有多篇文章,每个txt文件的命名格式为“页码_文章序号.txt”,例如第1页第3篇文章的文件名为“1_3.txt”。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值