unbalanced parenthesis




#!/usr/env  python
#-*- coding: utf-8  -*-
import urllib 
import urllib2 
import random 
import requests
import os,sys 
import MySQLdb
from sgmllib import SGMLParser 
from BeautifulSoup import BeautifulSoup
import re
num=0
def main():
	#try:
		#conn=MySQLdb.connect(host='localhost',user='root',passwd='123456',db='googlemarket',charset="utf8")
		#conn.query("set names utf8")
	#except Exception,e:
		#print e
		#sys.exit()
	#cursor=conn.cursor() 
	#for k in range(0,34):
		url="https://play.google.com/store/apps/details?id=com.androidesk&hl=zh_CNhttps%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.androidesk"
		#print k
		html=requests.get(url)
		preresult=html.content
		soup=BeautifulSoup(preresult)
		result=soup.prettify("utf-8")
		#名称
		pattern=re.compile('itemprop="name">[\s\S]*?<div>([\s\S]*?)</div>')
		data0=re.findall(pattern,result)
		for items in data0:
			print itemsunbalanced parenthesis
		#制造商
		pattern=re.compile('itemprop="name">([\s\S]*?)</a>')
		#data1=re.findall(pattern,result)
		#for items in data1
			#print items
		#版本
		pattern=re.compile('itemprop="softwareVersion">([\s\S]*?)</div>')
		data2=re.findall(pattern,result)
		print data2[0]
		#更新时间 
		pattern=re.compile('itemprop="datePublished">([\s\S]*?)</div>')
		data3=re.findall(pattern,result)
		#print data3[0]
		#文件大小
		pattern=re.compile('itemprop="fileSize">([\s\S]*?)</div>')
		data4=re.findall(pattern,result)
		#print data4[0]
		#支持固件
		pattern=re.compile('itemprop="operatingSystems">([\s\S]*?)</div>')
		data5=re.findall(pattern,result)
		#print data5[0]
		#说明
		pattern=re.compile('itemprop="description">[\s\S]*?<div>([\s\S]*?)</div>')
		data6=re.findall(pattern,result)
		for items in data6:
			pass#print re.sub('<br />',' ',items)
			#sql="insert into address(name,version,developer,pubtime,filesize,support,introduction) values(%s,%s,%s,%s,%s,%s,%s)"
			#for items in data6:
			
				#if(data5):
					#values=(data0[0],data1[0],data2[0],data3[0],data4[0],data5[0],re.sub('<br />',' ',items))
				#else:
					#values=(data0[0],data1[0],data2[0],data3[0],data4[0],'NULL',re.sub('<br />',' ',items))
				#print values
				#print sql % values
				#cursor.execute(sql,values)
				#conn.commit()
		pattern=re.compile('<img class="cover-image" src="(.+?)" alt')
		data=re.findall(pattern,result)
		global num
		for j in data:
			temp=requests.get(j[1:-2])
			f=file("googlemarket/"+str(num),"w+")
			f.write(temp.content)
	
			
		
				
	
    
if  __name__=="__main__":
       main()



Traceback (most recent call last):
  File "crawler0729.py", line 85, in <module>
    main()
  File "crawler0729.py", line 56, in main
    pattern=re.compile('itemprop="description">[\s\S]*?<div>"([\s\S]*?)"</div>')
  File "/usr/lib/python2.7/re.py", line 190, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python2.7/re.py", line 242, in _compile
    raise error, v # invalid expression
sre_constants.error: unbalanced parenthesis


missing right parenthesis

11-05

ERROR: eccl.web3.system.InfoList#GetCount : int GetCount()::SQLException : java.sql.SQLException: ORA-00907: missing right parenthesis rnrn这个错误怎么该啊rn下面是错误文件可是没找到错误啊rnpackage eccl.web3.system;rnimport eccl.web3.system.*;rnimport java.sql.SQLException;rnimport java.sql.ResultSet;rnimport java.sql.ResultSetMetaData;rnimport java.util.Hashtable;rnimport java.util.HashMap;rnimport java.util.ArrayList;rn//import log4j class packagernimport org.apache.log4j.PropertyConfigurator ;rnimport org.apache.log4j.Logger ;rnimport org.apache.log4j.Level ;rnimport java.sql.*;rnimport java.io.*;rn//import javax.servlet.http.HttpServletRequest;rnrnpublic class InfoList rn AppConfig appConfig=AppConfig.getInstance();rn String Max_line_Page_String;rn int Max_line_Page=20;rn int nowpage,Total,totalpage,movemun;rn String sqlcount,sqlplus;rn rn static Logger logger = Logger.getLogger(InfoList.class.getName());rn rn String sql="";rn rn /*rn 书据库的分类rn */rn String dbName="WEB3";rn rn DbServices dbServices;rn Connection conn;rn Statement stmt;rn ResultSet rs;rn public int GetMax_line_Page()return Max_line_Page;rn public int GetNowpage()return nowpage;rn public int GetTotal()return Total;rn public int GetTotalpage()return totalpage;rn public int GetMovemun()return movemun;rnrn public void SetMax_line_Page(int k) Max_line_Page=k;rn public void SetNowpage(int k) nowpage=k;rn public void SetTotal(int k) Total=k;rn public void SetTotalpage(int k) totalpage=k;rn public void SetMovemun(int k) movemun=k;rn rn public void setDbName(String dbName) this.dbName=dbName;rn public String getDbName() return this.dbName;rnrnrn public void InfoList() rn PropertyConfigurator.configure ( "log4j.properties" ) ;rn logger.info( "$Id: InfoList.java,v 1.14 2007/08/27 09:24:41 xuqiang Exp $" ) ;rnrn rn rnrn public int GetCount() throws Exception rn rnrn if(Total==0)rn sqlcount="Select count(*) as total from "+sql+" ";rn InitDb();rn tryrn rn rn stmt=conn.createStatement();rn rs=stmt.executeQuery(sqlcount);rn rn if(rs.next()) Total=rs.getInt("total");rn rs.close();rn stmt.close(); rn conn.close();rn rn catch (SQLException ex)rn rn tryrn if (! conn.isClosed()) conn.close();rn catch (SQLException ex1) rn logger.error( "int GetCount()::SQLException : " + ex ) ;rnrn rn finally dbclose(); sqlcount=null; rn rn rn rn return Total;rn rn rn public ArrayList GetInfoData(String sql) throws Exception rn rn rn this.sql=sql;rn ArrayList al=new ArrayList();rn FuncVal();rn InitDb();rn tryrn rn rn stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);rn rs=stmt.executeQuery(sql);rn ResultSetMetaData rsmd = rs.getMetaData();rn int PageInt=0; rn if(movemun!=0)rn //rs.next();rn rs.absolute(movemun);rn rn rn while(rs.next())rn HashMap hb= new HashMap();rn rn for(int i = 1; i <= rsmd.getColumnCount(); i++)rn rn String value=rs.getString(rsmd.getColumnName(i))==null?"":rs.getString(rsmd.getColumnName(i));rn hb.put(rsmd.getColumnName(i).toLowerCase(),value);rn rn rn al.add(hb); rn rn PageInt ++; rn rn if(PageInt == Max_line_Page) break; rn rn //rs.close();rn stmt.close(); rn conn.close();rn rn catch (SQLException ex)rn rn logger.error( " HashMap GetInfoData(boolean seltitle)::SQLException : " + ex ) ;rn tryrn if (! conn.isClosed()) conn.close();rn catch (SQLException ex1) throw ex1; rn rnrn rn finally dbclose(); rn rn return al; rn rn rn rn rn rn rn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭