Skip to content

Instantly share code, notes, and snippets.

View cors.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=
, initial-scale=1.0">
<title>Document</title>
</head>
View multiparty.js
app.use((req,res,next)=>{
console.log("req.headers", req.headers['content-type'])
if (req.path=='/formDataRoute') {
const formData = new multiparty.Form();
formData.parse(req, (err,fields,files) =>{
if (err) {
console.log(err)
req.body =undefined;
}else{
View feather.js
/* anladigim kadariyla, soyle bisey yapmak istiyorsunuz,
Sizin backend servisiniz (feather ile yazilmis) , Backend-Service diyelim,
bir de baska bir external service endpoint var , Backend-external diyelim.
Son olarak birde front-end olacak bunada front-end-client.
Sizin yapmak istediginizde , eger yanlis anlamadiysam,
1 - Backend-Service ve front-end-client in birebir bagli olmasi ve real-time olarak bagli kalmasi
2- Backend-external in da bu surecte ilgili oldugu kisimlari update olarak alabilmesi.
Burda, sizin backend-service iniz, olusturdugunuz feathers service araciligiyla aslinda bir proxy gorevi yapmis olacak,
sizin gonderdiginiz 1.yazida ki sekliyle yazmaniz yeterli.
View crawl.js
const puppeteer = require('puppeteer');
let url = 'https://www.n11.com/arama?q=';
let aramakriterleri = ['kablosuz klavye', 'hard disk', 'mouse', 'batarya', 'saat', 'dolap', 'masa', 'parfum', 'kanepe', 'buzdolabi', 'terlik', 'tencere', 'sepet', 'klima', 'kedi'];
let browser = null;
const crawl = async (arama) => {
View ntv.html
<!DOCTYPE html>
<html id="main-layout" ng-app="pluto">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html charset=UTF-8" />
<meta http-equiv="x-ua-compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
<title>NTV HABER - Haberler, Son Dakika Haberleri</title>
<link rel="amphtml" href="https://www.ntv.com.tr/amp" />
View package.json
{
"name": "crawler",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
View crawl.js
const puppeteer = require("puppeteer");
//#anaTablo-0 > thead > tr > th > strong > a
async function crawl({ url, cssSelector, output }) {
// parsing /crawling icin google headles browser i kullaniyoruz
// google bu module 'puppeteer' ismini vermis.
// scriptin gercek bir tarayiciyi acip olup biteni gormeni saglamasi icin
//{ headless: false } opsiyonu nu kullandik. Bu sadece gelistirme sureci icin
//kodun nihayi calisacak halinde bu { headless: true } olarak degistirilmelidir.
let broswer;
try {
View server.js
const express = require('express');
const bodyParser = require('body-parser');
const fs = require('fs');
const cors = require('cors');
const {crawl} = require('./crawler')
//web sunucusunu olustur.
const app = express();
//web sunucusu icin genel ayarlar.
app.set('json spaces', 2)
View callback.js
socket.on("login" , function(getData){
database.searchAccount(db,getData.username, getData.password , function (response) {
if (response) {
//kullanici login oldugunu varsayip sonraki islemleri burda yapman lazim
//response ancak burda deger tasir
console.log("response : ", response)
} else {