Driver={Microsoft Text Driver (*.txt; *.csv)

服务器不能调用 Driver={Microsoft Text Driver (*.txt; *.csv)} ,检查了几个小时才发现asp调用这个驱动要 Internet 来宾帐户(IUSR_XXX)列出文件夹目录 的权限,比较奇怪的是调用 driver microsoft access driver .mdb只要IUSR_XXX的 读取/写入 权限。

< %
Dim  Conn, rs
Set  Conn  =  Server.CreateObject( " ADODB.Connection " )
'  Set the Dbq portion of the string to the physical folder where your price files reside
Conn.Open  " Driver={Microsoft Text Driver (*.txt; *.csv)}; "   &  _
" Dbq=D:\web\web; "   &  _  ' 个人估计问题在这里,他要先列出里面的文件,而我们调用MDB这个路径是写死的,所以只要打开MDB文件,而不要历遍文件夹
" Extensions=asc,csv,tab,txt; "   &  _
" Persist Security Info=False "
Dim  sql
sql 
=   " SELECT * from web.csv "
' (implicit recordset creation through execute method)
set  rs  =  conn.execute(sql)
Response.write 
" <Table><TR BGCOLOR=lightgrey><TH>商品编号</TH><TH>商品名称</TH><TH>商品短名称</TH><TH>单位</TH><TH>商品积分</TH></TR> "
While   Not  rs.EOF
' here we have stock price text file in format: Date High Low Close Volume
Response.Write  " <TR bgcolor=lightblue><TD> "   &  rs( 0 &   " </TD><TD> "   &  rs( 1 ) _
&   " </TD><TD> "   &  rs( 2 &   " </TD><TD> "   &  rs( 3 &   " </TD><TD>  "   &  rs( 4 &   " </TD></TR> "
rs.MoveNext 
Wend
Response.write 
" </TABLE> "
rs.close
set  rs  =   nothing
conn.close
set  conn  =   nothing
%
>

转载于:https://www.cnblogs.com/LCX/archive/2009/08/10/1543068.html

运行代码后提示我页面结构变更,line56行报错,应该怎么处理, import csv from selenium import webdriver from bs4 import BeautifulSoup from urllib.parse import urljoin def getText(city, url, accumulated_text=“”): try: driver.get(url) driver.implicitly_wait(30) # 增加等待时间 soup = BeautifulSoup(driver.page_source, “lxml”) # 提取正文内容 content_div = soup.find(class_='content') if content_div: paragraphs = content_div.find_all('p') current_text = "".join([p.text.strip() for p in paragraphs]) accumulated_text += current_text else: accumulated_text += "【内容区域未找到】" # 查找下一页 next_page = soup.find('a', text='下一页') if next_page and 'href' in next_page.attrs: next_url = urljoin(url, next_page['href']) return getText(city, next_url, accumulated_text) # 递归处理下一页 # 没有下一页时保存结果 saveText(city, accumulated_text) except Exception as e: print(f"处理{city}时发生错误:{str(e)}") saveText(city, accumulated_text + "【抓取异常】") def saveText(city, text): with open(‘government_reports.csv’, ‘a’, newline=‘’, encoding=‘utf-8’) as f: csv.writer(f).writerow([city, text]) if name == ‘main’: # 初始化CSV文件 with open(‘government_reports.csv’, ‘w’, newline=‘’, encoding=‘utf-8’) as f: csv.writer(f).writerow([‘城市’, ‘报告内容’]) # 配置Edge浏览器驱动 driver = webdriver.Edge() try: # 获取目录页 driver.get("http://district.ce.cn/zt/2023/zfgzbg/index.shtml") soup = BeautifulSoup(driver.page_source, "lxml") # 验证容器元素存在 con_div = soup.find(class_='con') if not con_div: raise ValueError("页面结构已变更,未找到class='con'的容器") # 提取城市链接 city_links = [] for a_tag in con_div.find_all('a'): if not a_tag.has_attr('href') or not a_tag.has_attr('title'): continue city_links.append(( a_tag['title'], urljoin(driver.current_url, a_tag['href']) )) # 遍历所有城市页面 for city_name, link in city_links: print(f"正在处理:{city_name}") getText(city_name, link) finally: driver.quit() print("所有任务已完成,浏览器已关闭")
最新发布
03-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值