Commit 9387da00 by Ngô Trung Hưng

donwload csv

parent 85f48540
!function(e){e(["jquery"],function(e){return function(){function t(e,t,n){return g({type:O.error,iconClass:m().iconClasses.error,message:e,optionsOverride:n,title:t})}function n(t,n){return t||(t=m()),v=e("#"+t.containerId),v.length?v:(n&&(v=d(t)),v)}function o(e,t,n){return g({type:O.info,iconClass:m().iconClasses.info,message:e,optionsOverride:n,title:t})}function s(e){C=e}function i(e,t,n){return g({type:O.success,iconClass:m().iconClasses.success,message:e,optionsOverride:n,title:t})}function a(e,t,n){return g({type:O.warning,iconClass:m().iconClasses.warning,message:e,optionsOverride:n,title:t})}function r(e,t){var o=m();v||n(o),u(e,o,t)||l(o)}function c(t){var o=m();return v||n(o),t&&0===e(":focus",t).length?void h(t):void(v.children().length&&v.remove())}function l(t){for(var n=v.children(),o=n.length-1;o>=0;o--)u(e(n[o]),t)}function u(t,n,o){var s=!(!o||!o.force)&&o.force;return!(!t||!s&&0!==e(":focus",t).length)&&(t[n.hideMethod]({duration:n.hideDuration,easing:n.hideEasing,complete:function(){h(t)}}),!0)}function d(t){return v=e("<div/>").attr("id",t.containerId).addClass(t.positionClass),v.appendTo(e(t.target)),v}function p(){return{tapToDismiss:!0,toastClass:"toast",containerId:"toast-container",debug:!1,showMethod:"fadeIn",showDuration:300,showEasing:"swing",onShown:void 0,hideMethod:"fadeOut",hideDuration:1e3,hideEasing:"swing",onHidden:void 0,closeMethod:!1,closeDuration:!1,closeEasing:!1,closeOnHover:!0,extendedTimeOut:1e3,iconClasses:{error:"toast-error",info:"toast-info",success:"toast-success",warning:"toast-warning"},iconClass:"toast-info",positionClass:"toast-top-right",timeOut:5e3,titleClass:"toast-title",messageClass:"toast-message",escapeHtml:!1,target:"body",closeHtml:'<button type="button">&times;</button>',closeClass:"toast-close-button",newestOnTop:!0,preventDuplicates:!1,progressBar:!1,progressClass:"toast-progress",rtl:!1}}function f(e){C&&C(e)}function g(t){function o(e){return null==e&&(e=""),e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function s(){c(),u(),d(),p(),g(),C(),l(),i()}function i(){var e="";switch(t.iconClass){case"toast-success":case"toast-info":e="polite";break;default:e="assertive"}I.attr("aria-live",e)}function a(){E.closeOnHover&&I.hover(H,D),!E.onclick&&E.tapToDismiss&&I.click(b),E.closeButton&&j&&j.click(function(e){e.stopPropagation?e.stopPropagation():void 0!==e.cancelBubble&&e.cancelBubble!==!0&&(e.cancelBubble=!0),E.onCloseClick&&E.onCloseClick(e),b(!0)}),E.onclick&&I.click(function(e){E.onclick(e),b()})}function r(){I.hide(),I[E.showMethod]({duration:E.showDuration,easing:E.showEasing,complete:E.onShown}),E.timeOut>0&&(k=setTimeout(b,E.timeOut),F.maxHideTime=parseFloat(E.timeOut),F.hideEta=(new Date).getTime()+F.maxHideTime,E.progressBar&&(F.intervalId=setInterval(x,10)))}function c(){t.iconClass&&I.addClass(E.toastClass).addClass(y)}function l(){E.newestOnTop?v.prepend(I):v.append(I)}function u(){if(t.title){var e=t.title;E.escapeHtml&&(e=o(t.title)),M.append(e).addClass(E.titleClass),I.append(M)}}function d(){if(t.message){var e=t.message;E.escapeHtml&&(e=o(t.message)),B.append(e).addClass(E.messageClass),I.append(B)}}function p(){E.closeButton&&(j.addClass(E.closeClass).attr("role","button"),I.prepend(j))}function g(){E.progressBar&&(q.addClass(E.progressClass),I.prepend(q))}function C(){E.rtl&&I.addClass("rtl")}function O(e,t){if(e.preventDuplicates){if(t.message===w)return!0;w=t.message}return!1}function b(t){var n=t&&E.closeMethod!==!1?E.closeMethod:E.hideMethod,o=t&&E.closeDuration!==!1?E.closeDuration:E.hideDuration,s=t&&E.closeEasing!==!1?E.closeEasing:E.hideEasing;if(!e(":focus",I).length||t)return clearTimeout(F.intervalId),I[n]({duration:o,easing:s,complete:function(){h(I),clearTimeout(k),E.onHidden&&"hidden"!==P.state&&E.onHidden(),P.state="hidden",P.endTime=new Date,f(P)}})}function D(){(E.timeOut>0||E.extendedTimeOut>0)&&(k=setTimeout(b,E.extendedTimeOut),F.maxHideTime=parseFloat(E.extendedTimeOut),F.hideEta=(new Date).getTime()+F.maxHideTime)}function H(){clearTimeout(k),F.hideEta=0,I.stop(!0,!0)[E.showMethod]({duration:E.showDuration,easing:E.showEasing})}function x(){var e=(F.hideEta-(new Date).getTime())/F.maxHideTime*100;q.width(e+"%")}var E=m(),y=t.iconClass||E.iconClass;if("undefined"!=typeof t.optionsOverride&&(E=e.extend(E,t.optionsOverride),y=t.optionsOverride.iconClass||y),!O(E,t)){T++,v=n(E,!0);var k=null,I=e("<div/>"),M=e("<div/>"),B=e("<div/>"),q=e("<div/>"),j=e(E.closeHtml),F={intervalId:null,hideEta:null,maxHideTime:null},P={toastId:T,state:"visible",startTime:new Date,options:E,map:t};return s(),r(),a(),f(P),E.debug&&console&&console.log(P),I}}function m(){return e.extend({},p(),b.options)}function h(e){v||(v=n()),e.is(":visible")||(e.remove(),e=null,0===v.children().length&&(v.remove(),w=void 0))}var v,C,w,T=0,O={error:"error",info:"info",success:"success",warning:"warning"},b={clear:r,remove:c,error:t,getContainer:n,info:o,options:{},subscribe:s,success:i,version:"2.1.3",warning:a};return b}()})}("function"==typeof define&&define.amd?define:function(e,t){"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):window.toastr=t(window.jQuery)});
//# sourceMappingURL=toastr.js.map
...@@ -5,7 +5,7 @@ body { ...@@ -5,7 +5,7 @@ body {
} }
.app { .app {
overflow: hidden; overflow: hidden;
background-color: #f0f0f0; // background-color: #f0f0f0;
} }
$breakpoint-tablet: 992px; $breakpoint-tablet: 992px;
...@@ -624,7 +624,9 @@ $main-color: #221f20; ...@@ -624,7 +624,9 @@ $main-color: #221f20;
margin-top: 10px; margin-top: 10px;
margin-bottom: 5px; margin-bottom: 5px;
border-radius: 2px; border-radius: 2px;
border: 1px solid #999;
// border-top: 1px solid rgba($color: #000000, $alpha: 0.2);
border-bottom: 1px solid rgba($color: #000000, $alpha: 0.2);
transition: 0.2s; transition: 0.2s;
&:hover { &:hover {
transition: 0.2s; transition: 0.2s;
...@@ -856,6 +858,20 @@ $main-color: #221f20; ...@@ -856,6 +858,20 @@ $main-color: #221f20;
text-align: center; text-align: center;
color: #999; color: #999;
} }
.form_ftp {
width: 100%;
height: 82vh;
padding: 10% 0px;
}
.inp_ftp {
margin: auto;
width: 70%;
}
.btn_ftp {
width: 50%;
margin: auto;
text-align: center;
}
@media only screen and (min-width: $breakpoint-tablet) { @media only screen and (min-width: $breakpoint-tablet) {
.btn_search_submit { .btn_search_submit {
width: 101%; width: 101%;
......
...@@ -5,5 +5,6 @@ class HomeController < ApplicationController ...@@ -5,5 +5,6 @@ class HomeController < ApplicationController
@job_count = Job.all.count @job_count = Job.all.count
@five_jobs = Job.order(created_at: :asc).where(newdata: 1).limit(5) @five_jobs = Job.order(created_at: :asc).where(newdata: 1).limit(5)
@cities = City.all @cities = City.all
@top_city = City.top_hot.take(11)
end end
end end
...@@ -8,4 +8,15 @@ module ApplicationHelper ...@@ -8,4 +8,15 @@ module ApplicationHelper
"#{base_title} | #{page_title}" "#{base_title} | #{page_title}"
end end
end end
def custom_bootstrap_flash
flash_messages = []
flash.each do |type, message|
type = 'success' if type == 'notice'
type = 'error' if type == 'alert'
text = "<script>toastr.#{type}('#{message}');</script>"
flash_messages << text.html_safe if message
end
flash_messages.join("\n").html_safe
end
end end
...@@ -2,4 +2,12 @@ class City < ApplicationRecord ...@@ -2,4 +2,12 @@ class City < ApplicationRecord
has_many :city_jobs has_many :city_jobs
has_many :jobs, through: :city_jobs has_many :jobs, through: :city_jobs
def self.top_hot
hash = {}
data_cities = City.all
data_cities.each do |val|
hash[val.id] = val.jobs.count
end
hash.sort_by { |k,v| v }.reverse
end
end end
<header class="cus_header"> <header class="cus_header">
<div class="header_top"> <div class="header_top">
<div class="header_top_logo"> <div class="header_top_logo">
<%= link_to image_tag("logo.png", alt: "logo", class: "logo_header"), '#' %> <%= link_to image_tag("logo.png", alt: "logo", class: "logo_header"), '/' %>
</div> </div>
<input class="check-nav-mobile" type="checkbox" name="" id="mobile-nav" hidden> <input class="check-nav-mobile" type="checkbox" name="" id="mobile-nav" hidden>
<label for="mobile-nav" class="lbn-nav">&#9776</label> <label for="mobile-nav" class="lbn-nav">&#9776</label>
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
<body> <body>
<div class = "app"> <div class = "app">
<%= render 'layouts/header' %> <%= render 'layouts/header' %>
<%= custom_bootstrap_flash %>
<% flash.discard %>
<%= render 'layouts/padding' %> <%= render 'layouts/padding' %>
......
<div class="box_info_city"> <div class="box_info_city">
<div class="ct_name"> <div class="ct_name">
<%= link_to 'Hồ Chí Minh', '#' ,class: 'link_ct'%> <% data = City.find(k) %>
<%= link_to data.name, '#' ,class: 'link_ct'%>
</div> </div>
<div class="ct_jobs_count"> <div class="ct_jobs_count">
<%= link_to '69 Công việc', '#' ,class: 'link_ct'%> <%= link_to "#{v} công việc", '#' ,class: 'link_ct'%>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
<span>Top thành phố</span> <span>Top thành phố</span>
</div> </div>
<div class="row no-gutters"> <div class="row no-gutters">
<% 11.times do |item| %> <% @top_city.each do |k,v| %>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12"> <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
<%= render 'shared/block_cities_hot' %> <%= render 'shared/block_cities_hot',k: k, v: v %>
</div> </div>
<% end %> <% end %>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12"> <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
......
...@@ -14,7 +14,7 @@ default: &default ...@@ -14,7 +14,7 @@ default: &default
encoding: utf8 encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root username: root
password: '12345678' password: '1'
socket: /var/run/mysqld/mysqld.sock socket: /var/run/mysqld/mysqld.sock
......
Rails.application.routes.draw do Rails.application.routes.draw do
get 'ftp/upload'
post 'ftp/new'
get 'ftp/new', to: 'ftp#index'
match '/ftp', to: 'ftp#index', via: 'get'
post 'ftp/new'
# match '/ftp', to: 'ftp#index', via: 'post'
# get 'home/index' # get 'home/index'
root 'home#index' root 'home#index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
......
This source diff could not be displayed because it is too large. You can view the blob instead.
File added
...@@ -39,7 +39,7 @@ class Clawler ...@@ -39,7 +39,7 @@ class Clawler
# FILL DATA COMPANIES # FILL DATA COMPANIES
def self.make_companies def self.make_companies
Company.create!(name: "Company name", Company.create!(name: "Bảo mật",
address: "Vui lòng xem trong mô tả công việc", address: "Vui lòng xem trong mô tả công việc",
short_description: "Vui lòng xem trong mô tả công việc") short_description: "Vui lòng xem trong mô tả công việc")
@data = Interface_web.craw_data_companies() @data = Interface_web.craw_data_companies()
...@@ -116,7 +116,7 @@ class Clawler ...@@ -116,7 +116,7 @@ class Clawler
id_cities = City.find_by name: city.strip id_cities = City.find_by name: city.strip
if !id_cities if !id_cities
id_cities = City.create!(name: city.strip).id id_cities = City.create!(name: city.strip, area: 1).id
else else
id_cities = id_cities.id id_cities = id_cities.id
end end
......
class FTP_sever
CONTENT_SERVER_DOMAIN_NAME = '192.168.1.156'
CONTENT_SERVER_USER_NAME = 'training'
CONTENT_SERVER_USER_PASSWORD = 'training'
def self.donwload_csv
Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_USER_NAME, CONTENT_SERVER_USER_PASSWORD) do |ftp|
debugger
@file = ftp.getbinaryfile('jobs.zip')
@file.save!
puts "#{Time.now} << 'Donwload jobs.zip'"
end
end
end
\ No newline at end of file
...@@ -21,9 +21,9 @@ class Interface_web ...@@ -21,9 +21,9 @@ class Interface_web
data << website_companies << website_jobs data << website_companies << website_jobs
end end
@crawl_link_for_companies_jobs = crawl_link_for_companies_jobs(3) @crawl_link_for_companies_jobs = crawl_link_for_companies_jobs(5)
def self.get_link_job_and_companies def self.get_link_job_and_companies
@crawl_link_for_companies_jobs ||= crawl_link_for_companies_jobs(3) @crawl_link_for_companies_jobs ||= crawl_link_for_companies_jobs(5)
end end
def self.base_link(url) def self.base_link(url)
...@@ -146,7 +146,7 @@ class Interface_web ...@@ -146,7 +146,7 @@ class Interface_web
@created_date << "" @created_date << ""
expiration_date = page.search(".info li:nth-child(4)").text expiration_date = page.search(".info li:nth-child(4)").text
if expiration_date == "" if expiration_date.blank?
@expiration_date << "" @expiration_date << ""
else else
@expiration_date << expiration_date.to_s.delete!("[\n,\t,\r]").split(' ').last @expiration_date << expiration_date.to_s.delete!("[\n,\t,\r]").split(' ').last
...@@ -159,14 +159,19 @@ class Interface_web ...@@ -159,14 +159,19 @@ class Interface_web
@description << page.search(".left-col").to_s.delete!("[\n,\t,\r]") @description << page.search(".left-col").to_s.delete!("[\n,\t,\r]")
lv = page.search(".boxtp .info li:nth-child(2)").text lv = page.search(".boxtp .info li:nth-child(2)").text
if lv == "" if lv.blank?
@level << "" @level << ""
else else
@level << lv.delete!("[\n,\t,\r]").strip.split('Cấp bậc').last.strip @level << lv.delete!("[\n,\t,\r]").strip.split('Cấp bậc').last.strip
end end
# if exp == ""
# @exprience << ""
# else
# @exprience << exp.delete!("[\n,\t,\r]").split('Kinh nghiệm').last.strip
# end
exp = page.search(".info li:nth-child(6)").text exp = page.search(".info li:nth-child(6)").text
if exp == "" if exp.blank?
@exprience << "" @exprience << ""
else else
@exprience << exp.delete!("[\n,\t,\r]").split('Kinh nghiệm').last.strip @exprience << exp.delete!("[\n,\t,\r]").split('Kinh nghiệm').last.strip
...@@ -278,7 +283,9 @@ class Interface_web ...@@ -278,7 +283,9 @@ class Interface_web
page = Nokogiri::HTML(URI.open(URI.parse(URI.escape("https://careerbuilder.vn/#{path}")))) page = Nokogiri::HTML(URI.open(URI.parse(URI.escape("https://careerbuilder.vn/#{path}"))))
if page.search(".item-blue .detail-box:nth-child(1) ul li:nth-child(1) p")[0] != nil if page.search(".item-blue .detail-box:nth-child(1) ul li:nth-child(1) p")[0] != nil
crawl_data_jobs_interface_1(path) crawl_data_jobs_interface_1(path)
elsif page.search(".DetailJobNew ul li").size == 10 elsif page.search("section .template-200").text != ""
crawl_data_jobs_interface_2(path)
elsif (page.search(".DetailJobNew ul li").size == 10 && !page.search('.right-col ul li').text.include?('Độ tuổi'))
crawl_data_jobs_interface_5(path) crawl_data_jobs_interface_5(path)
end end
puts "Process: #{current_job}/#{total_jobs}" puts "Process: #{current_job}/#{total_jobs}"
...@@ -287,7 +294,7 @@ class Interface_web ...@@ -287,7 +294,7 @@ class Interface_web
@data @data
end end
end end
# elsif page.search(".info li").text != ""
# crawl_data_jobs_interface_2(path)
# else # insert "page.search(".DetailJobNew ul li").size == 8" (if want catch interface 4) # else # insert "page.search(".DetailJobNew ul li").size == 8" (if want catch interface 4)
# crawl_data_jobs_interface_3(path) # crawl_data_jobs_interface_3(path)
\ No newline at end of file
require 'src/crawler' require 'src/crawler'
namespace :db do namespace :db do
task populate: :environment do task populate: :environment do
Clawler.make_industries # Clawler.make_industries
Clawler.make_cities Clawler.make_cities
Clawler.make_companies Clawler.make_companies
Clawler.make_jobs Clawler.make_jobs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment