야후사전을 이용해서 사전을 만들고 싶은데..

익명 사용자의 이미지

사실은 C로 야후사전을 이용해서 사전을 만들려고 하는데요..

기본적으로 html을 받아와야 할텐데..

제 생각으로 소켓으로 연결하고
"GET /index.html "
하면 될줄 알았는데.. 안되네요..

그래서 혹시나 해서

telnet kr.yahoo.com 80 하고 나서
GET /index.html

해도 안되더군요.. ㅠㅠ

아직 검색실력이 모자라서 그런지.. 이런것에 관한거는 잘 몰라서요...

어떻하면 html화일을 받을수가 있을까요??

받고 나서도 많은 태그들을 지워야 할텐데...

첫단추부터 막히네요...

일단은 이것을 해결한다음에..qt를 이용해서 만들어 볼생각입니다.

도와주세요

익명 사용자의 이미지

사용법 ./a.out xxx.xxx.xxx
빨리 만들다보니.. 도메인이름 을 지원하는건 생략했습니다.
IP로만 아규먼트 사용할수 있습니다.

#include
#include
#include
#include
#include
#include
#include
#include

int main(int argc, char **argv)
{
int client_len;
int client_sockfd;
int n = 0;

char buf_in[1024];
char buf_get[255];

struct sockaddr_in clientaddr;

client_sockfd = socket (AF_INET, SOCK_STREAM, 0);
clientaddr.sin_family = AF_INET;
clientaddr.sin_addr.s_addr = inet_addr(argv[1]);
clientaddr.sin_port = htons(80);

client_len = sizeof(clientaddr);

if (connect(client_sockfd, (struct sockaddr *)&clientaddr, client_len) < 0)
{
perror("connect error ");
exit(0);
}

write(client_sockfd, "GET / HTTP/1.0\n\n", 255);

memset(buf_in, '\0', 1024);
while((n = read(client_sockfd, buf_in, 1024) > 0))
{
printf("%s", buf_in);
memset(buf_in, '\0', 1024);
}
}

익명 사용자의 이미지

감사합니다.

GET / HTTP/1.0

이었군요....
이걸 이용해서... 다행히 index.html 을 쉽게 받아 올수 있었습니다.

근데.. 해보니까... 절대 경로로 해주는게 조금더 안정적이더군요...

http//kr.engdic.yahoo.com/result.html 을 보고 싶다면..

GET http//kr.engdic.yahoo.com/result.html HTTP/1.0 이렇게 하는게 좋더군요..

아참 엔터를 두번치는거 잊으면 안됩니다. 히히..

이제 남은 것은 많은 테그를 없애줘야할테데... 걱정입니다...

어떤방법으로 하는게 효과적일까요??

너무 바라는건가?? 죄송합니다...

익명 사용자의 이미지

C에.. html 파싱하는 라이브러리가 있긴할건데..
(물론 직접 코딩하는 방법도 있겟지만, 좀 시간이 걸리겠죠)
QT를 사용하신다면.. KDE 의 html 관련 클래스를 사용해서
처리를 하시는게 빠를것 같습니다.
www.kde.org 가셔서 develop.kde.org 인가 찾아가셔서 kde 라이브러리 레퍼런스
문서를 보면 Khtml 을 설명한 문서가 있습니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.