먼저 로컬에 저장된 크롤링 된 HTML 페이지를 저장해야합니다. 나는 성공적으로Python에서 MySQL에 HTML 저장
myHTML = open(file_location,'r').read()
출력을 사용하여 파일을 여는하고는 여기에서 볼 수 있습니다 : http://shrib.com/jqR5uf0C는
나는 또한 성공적으로 SQL 쿼리를 만들는 :
query_insert = ("insert into job_html (processid, myURL, myhtml) VALUES (%d, %s, %s)", processid, my_url, str(myHTML))
하지만 어떤 이유로
되는 HTML 이스케이프되지 제대로 파이썬이나 수동으로 삽입 할 수 없습니다.또한 다음과 같은 파이썬 오류가 점점 오전 :
AttributeError: 'tuple' object has no attribute 'encode'
어떤 도움 파이썬 초보자 ;-)에서 감사를
코드 :
데프 extractText (file_location, 프로세스 id, my_url) :
import mysql.connector
iwr_db = mysql.connector.connect(user='iwr', password='iwr',
host='127.0.0.1',
database='iwr_1')
myHTML = open(file_location,'r').read()
query_insert = ("insert into job_html (processid, myURL, myhtml) VALUES (%d, %s, %s)", processid, my_url, str(myHTML))
print query_insert
cursor_insert = iwr_db.cursor(buffered=True)
cursor_insert.execute(query_insert)
iwr_db.commit()
a) 실제 MySQLdb 실행 호출과 b) 전체 추적? 동일한 기능의 –
. HTML을 간단한 문자열로 바꿀 때 제대로 작동합니다. SQL 쿼리를 출력하고 수동으로 mysql에 삽입하려고하면 실패한다. '추적 장치'가 의미하는 바를 모르겠 음 – Markus
한숨. 내가 "어디 있는지"라고 말하면 "게시 할 수 있습니까?"라는 의미입니다. –