스크래핑,파싱
[파싱,스크래핑,크롤링] php 파싱시 insert 오류 날때 해결방법
xemaker
2018. 5. 2. 14:00
스크래핑해서 db 에 insert를 해야할때 이상한문자가 insert 될 수도 있고 문장에 ' 가 있으면 insert 오류가 날 수도 있다.
언제 어디서 오류가 날 수 있고 오류가 안나다가 갑자기 날 수도 있기 때문에
아래 4개 php 함수를 그냥 디폴트로 쓰는게 좋을듯...
html을 벗겨내고 싶을때 strip_tags
가 나올때 str_replace
< 등이 나올때 htmlspecialchars_decode
'가 있어서 쿼리문 오류 날때 addslashes
$title=strip_tags($title);
$title=str_replace(" "," ",$title);
$title=htmlspecialchars_decode($title);
$title=addslashes($title);